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

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.

Reply
Anonymous
Not applicable

How to apply multiple distinct counts

I have a table that i need to count distinct values from. See simplified table example below (latest hour for day is a calculated column)

UserIDDateHourLatest Hour for day
John Smith10/01/20201010
John Smith10/01/20201010
John Smith11/01/202099
Sam Benson10/01/20201010
Sam Benson11/01/20201012
Sam Benson11/01/20201212

 

I need to have multiple measures (for each hour of the working day - roughly 12 hours). For example i need the measure for hour 10 to tell me how many times a users latest hour for the day = 10. But this can only count the the same user once per day and it needs to count every single day in the range. In the table example above for hour 10 it should return 2 because on 10/01/2020 both John Smith and Sam Bensons latest hour was 10. Sometimes one user will may multiple rows for the same date and hour which complicates things.

 

Hope this makes sense,

Thanks

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

did not get completely is with example

but

calculate(distinctcount(UserID),filter(table, [hour]= [latest hour of day] && [hour] =10))

 

The date and hour can filter from slicer. Also you can have flag created as column where hour = lastest hour. Using ealier you can flag each date.

 

Can provide more details and  explain with an example. If possible please share a sample pbix file after removing sensitive information.
Thanks.

My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/Winner-Topper-on-Map-How-to-Color-States-on-a-Map-wi...
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

did not get completely is with example

but

calculate(distinctcount(UserID),filter(table, [hour]= [latest hour of day] && [hour] =10))

 

The date and hour can filter from slicer. Also you can have flag created as column where hour = lastest hour. Using ealier you can flag each date.

 

Can provide more details and  explain with an example. If possible please share a sample pbix file after removing sensitive information.
Thanks.

My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/Winner-Topper-on-Map-How-to-Color-States-on-a-Map-wi...
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

Anonymous
Not applicable

Thanks for this. I think you're on the right lines. I think it counts all the rows i need but due to the distinct count it only counts each userID once when it needs to count it once per day.

Please provide output example.

Hi @Anonymous 

What does this mean?

I think it counts all the rows i need but due to the distinct count it only counts each userID once when it needs to count it once per day

 

Could you show some examples?

 

Best Regards
Maggie

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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