I have a Data Frame with one column in each row of this column there is a list with 2 numbers. The first number is an integer and the second number is double. For example row 1 is [12, 14.5] and row 2 is [21, 27.3]. How can I divide this list into 2 columns so I will have the first number of list in one column and second number of the list in another column?
The thing that you need to add or update in your code :
df = df.select(col('vals.val1').alias("val1"), col('vals.val2').alias("val2"))
Related
I have a matrix that has numerous categories/columns with a total of each row. I want a specific column to remain in the matrix, but should not form part of the row total.
Dog
Cat
Chicken
Total (Excl. Chicken)
2
2
10
4
2
4
100
6
I only find ways to either remove the row total of the column totals for specific columns. Also appear that measures does not work in matrix's. Do I need to rather use a table with a added measure or is there a way with a matrix?
Please, how to divide 2 numeric columns in SAS.
For example, the first colum is readmission, the second column is the total_admission, and I need to create a third column called readmission_rate by dividing column A / B
Simply
readmission_rate = readmission / total_admission ;
In this scenario, I am looking to total Columns G through M by 'user' in Column E. Column N does have the correct data, but it is using the formula =sum(f4:m5). I am looking for a way to add an array formula because the heights of the merged cells in column N varies often. A formula would be preferred to a script in this case.
try:
=INDEX(IFNA(VLOOKUP(F2:F,
QUERY(SPLIT(FLATTEN(IF(G2:M="",,F2:F&"♀"&G2:M)), "♀"),
"select Col1,sum(Col2) group by Col1"), 2, 0)))
i want to create a calculated column, which will show two values: Y or N
2 columns are here important, "VAT-ID" and "CUSTOMER-ID". the calculated column will check if a customer-ID has multiple VAT-IDs. If yes the value "Y" should be displayed, else "N".
for example, the first 5 rows of the customer-id column are:
123456
654321
666666
123456
654321
the first 5 rows of the VAT-id column are:
EE999999999
AA999999999
GG999999999
KK999999999
AA999999999
the first 5 rows of the calculated column should be then:
Y
N
N
Y
N
any Help would be appreciated
Calculated columns don’t allow for aggregations across groups or other than the current row.
What you can do to achieve your goal is to create a separate aggregation node and count distinct VAT-IDs grouped by CUSTOMER-ID.
With this, you can now have a calculated column that checks for VAT-ID-COUNT > 1 and map it to your Y/N values.
As Lars mentioned it is not possible to use a window function within a calculated field on HANA table
But you can use following query to check if VAT number is multiple for a customer or not
select
CustomerId, VATID,
case
when (count(*) over (partition by CustomerId, VATID)) > 1
then 'Y'
else 'N'
end
from CustomerVAT;
I have a problem to solve similar to the example in the image below. I have the values of Column 1, 2 and 3, and want to get the calculated values exampled in Column 4. These are the number of times that the same number of Column 3 appears for different combinations of values from Column 1 and 2.
Thanks in advance for any help!
If your table has as name 'table1',
then the following dax statement will calculate column4.
Column4 = CALCULATE(countrows(Table1);filter(Table1;Table1[Column3]= EARLIER(Table1[Column3])))
Keep in mind that based on regional settings, you have to replace the ; with , in the example provided.