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
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!

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.