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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
peterver
Frequent Visitor

Count Distinct users per date but group result by rank of users

I have a table with time booking data like - 

 

Date               User          Activity            Hours
01/01/2019    Name A    Work                5
01/01/2019    Name A    Annual Leave   5
01/01/2019    Name B    Work               10
01/01/2019    Name C    Work               10
02/01/2019    Name A    Work               10
02/01/2019    Name D    Annual Leave  10
02/01/2019    Name C    Work               12

 

And a lookup table with ranks like -

 

User          Rank
Name A    Manager
Name B    Manager
Name C    Associate
Name D    Employee

 

I want create a measure, or a combination of measures, to count the distinct number of users per date, but return the count of each rank per date.

 

So for 01/01/2019 it would return Manager = 2, Associate = 1

for 02/01/2019 it would return Manager = 1, Associate = 1, Employee = 1

 

I can get a count of the distinct users per date with a simple measure like this - 
 

 

Count of User total for Date = 
CALCULATE(
	DISTINCTCOUNT('Table'[User]),
	ALLSELECTED('Table'[Date])
)

 

 

 

Is it possible to return a count of the rank per date based on distinct users per date? 

 

Thanks for any help!

 

1 ACCEPTED SOLUTION
v-lili6-msft
Community Support
Community Support

hi @peterver 

For your case, adjust your model as below:

1. Create a relationship between between two tables by [User] column.

2. Adjust the measure as below:

Count of User total for Date = 
CALCULATE(DISTINCTCOUNT('Table'[User]))

3. Create a visual that contains [Rank] column,[Date] column and this measure.

5.JPG

and here is my sample pbix file, please try it.

 

Regards,

Lin

Community Support Team _ Lin
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

2 REPLIES 2
v-lili6-msft
Community Support
Community Support

hi @peterver 

For your case, adjust your model as below:

1. Create a relationship between between two tables by [User] column.

2. Adjust the measure as below:

Count of User total for Date = 
CALCULATE(DISTINCTCOUNT('Table'[User]))

3. Create a visual that contains [Rank] column,[Date] column and this measure.

5.JPG

and here is my sample pbix file, please try it.

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Greg_Deckler
Super User
Super User

Just include your Rank column in your visual?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.