Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
gokar1ap
Frequent Visitor

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. 

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

lbendlin_0-1712589666253.png

 

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]))

View solution in original post

2 REPLIES 2
gokar1ap
Frequent Visitor

You are awesome. Worked like a charm. Thanks so much @lbendlin!

lbendlin
Super User
Super User

lbendlin_0-1712589666253.png

 

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]))

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.