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.
Related
I am having an issue using the Distinctcount function in DAX. I have a table with a total of 1,154,493 rows. I have a measure created to count the number of distinct values in column 1. I have another measure created to count the number of distinct values in column 1 with filters. I have a 3rd and final measure created to count the number of distinct values of column 1 with different filters. The issue I am running into is the count of measure 2 + measure 3 should equal measure 1 however added together they are GREATER than the value of measure 1 which is just a grand total. How is this possible? Unfortunately I can't share the table but below is the code I am using for the two measures:
Measure1=distinctcount('Table1'[Column1])
Measure2=calculate(distinctcount('Table1'[Column1]),'Table1'[CTest] = 1,'Table1'[CTest2] = "07")
Measure3=calculate(distinctcount('Table1'[Column1]),'Table1'[CTest] = 2,'Table1'[CTest2] = "07")
I am at a loss. Thank you in advance!!
For troubleshooting you should identify values of Column1 with Measure2 and Measure3 > 0, those are being added twice.
I've tried add calculated column to my table in power bi. Now I have two columns:
Num_of_occurence=CALCULATE(COUNT(Loans[ID]))
which calculates how may times specific loan occurs in this table
Num_of_all_loans=COUNTROWS(Loans)
calculation of number of all loans in table. What I've tried to add is calculated column which calculated percentage
Percent=DIVIDE([Num_of_occurence];[Num_of_all_loans])
The proble is I got circular dependency error. Any idea how to solve it?
You don't need calculated Filed rather you need Measure.
Use the same formula but rather than calculated column create Measure and you shall have your result
Column = CALCULATE(DIVIDE([No of Occurence];[Num_of_all_loans]))
Making a measure solved the problem for it! Thanks.
Measure 1 = CALCULATE(VALUES('All Rates_OTM'[SCAC]))
Measure 2 = CALCULATE(VALUES('All Rates_OTM'[SCAC]))
Comparison calculated column:
IsPreferredCarrier = IF('Table 1'[Measure 1] = 'Table 2'[Measure 2], "Yes", "No")
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'm trying to get a sum of my sales figures by the product category from the a column in the same table
The original data is on the attached image.
Original Data
And what I'm trying to get is attached also and I am having trouble getting the right numbers for the last three columns
Result
I have tried the following code:
Boots_Sales = CALCULATE( SUM(Sheet1[Sales]), FILTER(Sheet1,Sheet1[Product_Type]="Boots"))
I have found a solution to the above by making a measure instead of a column with the below formula:
boot1 = CALCULATE(SUM(original[Sales]),FILTER(original,original[Product type ]="Boots"))
This will have to do, I was trying to make a column because I wanted to do further calculations on the column but will just have to convert the measure into a column
Thanks
https://i.stack.imgur.com/BTjZv.jpg
I am trying to generate a calculated column B from column A. Notice that column B is basically the same rows as column A except it's offset by 2 rows. I'm trying to generate this with DAX but I don't even know where to begin. I would appreciate any help.
You can use in PowerBI the PowerQuery Editor to append a Column with 2 "null" values (as numeric type) like the example below:
append column in powerbi example
To get this result:
final result of "column B"
Think is a easy way to get what you want.