Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi,
I have a table with sales orderlines:
I have a related table via an item table with the manufacturer of each item (the item no is stored in the column "No")
I want to create a measure which counts the distinct values of the column "Document_No" (which stores the order number which has 1..n sales orderlines) if the following two criterias are met:
If possible without creating another table which groups the sales orderlines by "Document_No".
Many thanks!
Solved! Go to Solution.
CALCULATE(CALCULATE(DISTINCTCOUNT(Sales[Document_No]), FILTER(ALL(Sales[Document_No]), CALCULATE(COUNT(Sales[Line_No])) = 5), Sales[Line_Amount] = 0), Sales[Manufacturer] = "Super Duper")
OR
CALCULATE(COUNTROWS(FILTER(VALUES(Sales[Document_No]), CALCULATE(COUNT(Sales[Line_No])) = 5)), Sales[Line_Amount] = 0), Sales[Manufacturer] = "Super Duper")
CALCULATE(CALCULATE(DISTINCTCOUNT(Sales[Document_No]), FILTER(ALL(Sales[Document_No]), CALCULATE(COUNT(Sales[Line_No])) = 5), Sales[Line_Amount] = 0), Sales[Manufacturer] = "Super Duper")
OR
CALCULATE(COUNTROWS(FILTER(VALUES(Sales[Document_No]), CALCULATE(COUNT(Sales[Line_No])) = 5)), Sales[Line_Amount] = 0), Sales[Manufacturer] = "Super Duper")
Yes the second option would have the issue not the first. The second option then would have to be tweaked slightly to account for that something like:
CALCULATE(COUNTROWS(FILTER(VALUES(Sales[Document_No]), CALCULATE(COUNT(Sales[Line_No]), ALLEXCEPT(Sales, Sales[Document_No])) = 5)), Sales[Line_Amount] = 0), Sales[Manufacturer] = "Super Duper")
The measure works as expected but I didn't realize there could be more than one combination in one Document_No.
Example:
Article A, B, C, D, E all belong to Brand "Super Duper". In the same Document_No those Articles A, B, C, D have Line_Amount > 0, E has Line_Amount = 0. All articles have Quantity = 10. The formula shows Result = 1 but should show 10.
I think the easiest way to fix this would be to sum the Quantity of the article with Line_Amount=0 in Document_No which have 5 articles of "Super Duper" and one of these articles has Line_Amount=0.
If there are other articles than of Brand "Super Duper" with Line_Amount = 0 they must not be counted.
Is there a solution for this?
Hi srinivt,
I tried your first solution, works like a charm! Thanks alot!!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
100 | |
80 | |
64 | |
57 |
User | Count |
---|---|
146 | |
110 | |
93 | |
84 | |
67 |