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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
racer25
New Member

COUNT DISTINCT

Hi 

 

I am new to PBI as our company has long since used Qlikview but transitioning to PBI.

 

I have spent a decent amount of time trying to figure this one out and while I am narrowing in on the answer I am either getting the wrong answer or errors.

 

I have 4 relebant fields

 

Worker , Approval Date, Expense ID, Amount

 

I am using a table and want to show Worker, Sum Amount by Approval Date Year and Distinct Count of Expense ID.

 

Sum Amount by Year is done.

 

Count Distinct Expense ID's is my problem= If the Worker has no claims in the Year the Count is 1 not zero.

 

Any thought that could help? I have tried various add column options and DISTINCYCOUNTNOBLANKS.

 

Thanks in advance,

 

Rob

 

 

 

1 ACCEPTED SOLUTION
bhanu_gautam
Super User
Super User

@racer25 You need to create a measure that calculates the distinct count of Expense IDs for each worker and year, and handles cases where there are no claims correctly.

 

dax
DistinctExpenseCount =
VAR DistinctCount = DISTINCTCOUNT('YourTable'[Expense ID])
RETURN
IF(DistinctCount = BLANK(), 0, DistinctCount)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

2 REPLIES 2
bhanu_gautam
Super User
Super User

@racer25 You need to create a measure that calculates the distinct count of Expense IDs for each worker and year, and handles cases where there are no claims correctly.

 

dax
DistinctExpenseCount =
VAR DistinctCount = DISTINCTCOUNT('YourTable'[Expense ID])
RETURN
IF(DistinctCount = BLANK(), 0, DistinctCount)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Thanks so much - PBI didn't like the VAR Name of DistinctCount but a quick tweak and working. It also gave me an understanding of how to do it not just copy/[aste - appreciate the support

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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