Forum Discussion
DAX measure issue with Distinct Row Count.
Objective: Create a DAX measure which gives me a unique row count based on 'Product' column. The condition is based on users, usage and month column.
Problem: For condition, Users = 0 and Usage = 0, the result of my row count is 2 because my DAX seems to calculate count of Product A + Product B. The expected value should be 1.
Expected Result: I want my DAX to give me a distinct/unique count of Products if all USERS & USAGE & All MONTHS for each product is equal to 0. The expected count value should be 1 (Product B) based on my sample data below.
I have Table A with the following columns and values:
Product | Month | Users | Usage
A | 1/1/2022 | 0 | 0
A | 2/1/2022 | 1 | 1
A | 3/1/2022 | 1 | 1
B | 1/1/2022 | 0 | 0
B | 2/1/2022 | 0 | 0
B | 3/1/2022 | 0 | 0
C | 1/1/2022 | 1 | 1
C | 2/1/2022 | 1 | 1
C | 3/1/2022 | 1 | 1
Here's my current DAX Measure that is not giving me the required result count:
Unused Products =
CALCULATE
(DISTINCTCOUNT('TableA'[Products]),
'TableA'[Users] == 0 && 'TableA'[Usage] == 0
) + 0
Can you please help me fix my DAX? I appreciate all your help in advance.
Zero Usage Products = var a = SUMMARIZE('TableA',[Product],"r",COUNTROWS('TableA'),"z",CALCULATE(COUNTROWS('TableA'),'TableA'[Usage]=0,'TableA'[Users]=0)) return COUNTROWS(filter(a,[r]=[z]))