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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Sashwato
Helper II
Helper II

Need help with Occurrence of Distinct Count

Hello all,

 

I am trying to do a distinct count of people based on date ending period. So, if a person in Region X under Project A is counted once for a date period, then he/she need not be counted again for any other region and project as well. This is characterized by Date field available. Below screenshot is from the PowerQuery setup:

 

Sashwato_0-1627366781977.png

 

As you can see from above, I merged the Date and the username to generate a unique Index ID. I plotted a matrix chart to check and below is something I am getting:

 

Test data snapshot.PNG

 

If you take a look, on 1/31/2021 - Danny is distinct counted multiple times in projects: ABC, ZKY and GHI. We want Danny to be counted only once for that date period 1/31/2021. Currently I am doing Distinct count of the INDEX column. Please suggest any solution for the same.

 

Any help is appreciated.

 

Regards!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Sashwato ,

 

You can add an index column like

10.png

11.png

 

The Merged column is created by dax

 

 

Merged = [Date]&"-"&[Username]

 

 

Then I create the following rank column

 

 

Rank = RANKX(FILTER('Table',[Merged]=EARLIER('Table'[Merged])),[Index],,ASC,Dense)

 

 

12.png

 

Finally create a measure

 

 

Measure = IF(MAX('Table'[Rank])=1,1)

 

 

13.png

You can click Show items with no data to display empty values.

14.png

 

 

Check more details from the attachment

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @Sashwato ,

 

You can add an index column like

10.png

11.png

 

The Merged column is created by dax

 

 

Merged = [Date]&"-"&[Username]

 

 

Then I create the following rank column

 

 

Rank = RANKX(FILTER('Table',[Merged]=EARLIER('Table'[Merged])),[Index],,ASC,Dense)

 

 

12.png

 

Finally create a measure

 

 

Measure = IF(MAX('Table'[Rank])=1,1)

 

 

13.png

You can click Show items with no data to display empty values.

14.png

 

 

Check more details from the attachment

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Sashwato , In the project view it will be counted or shown multiple times. But as you can see on grand total it counted once. That is correct.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Yes @amitchandak true. I agree, however our management would like to see the count against the name being shown once once rather than 3 times in other projects since they would like to track it on individual basis. 

Is there a measure or something that helps with it?

 

Regards!

@Sashwato , Try a measure like

measure =
var _1 = calculate(min(Table[project]), filter(allselected(Table) ,Table[project] = min(Table[project] ))
return
if( not(isblank(distinctCOUNT(Table[Index]))) && max(Table[project]) =_1 , distinctCOUNT(Table[Index]), blank())

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you @amitchandak 

 

I tried using the measure to my context as below:

Updated measure =
var _1 = calculate(min(Sheet1[Client]), filter(allselected(Sheet1) ,Sheet1[Client] = min(Sheet1[Client] )))
return
if( not(isblank(DISTINCTCOUNT(Sheet1[Index]))) && max(Sheet1[Client]) =_1 , DISTINCTCOUNT(Sheet1[Index]), blank())
 
I am seeing the below results still the same as it shows 1 on ABC, ZKY and GHI for Danny on 1/31/2021:
 
Capture27.PNG

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors