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.
Hello!
I have the below table, and what I need, for a period, the max number of people on a day. For example:
Person | Day | Schedule |
John | 01/01/2021 | Morning |
Esther | 02/01/2021 | Evening |
Maria | 01/01/2021 | Morning |
Pedro | 01/01/2021 | Evening |
John | 02/01/2021 | Morning |
Outcome:
If I filter by all dates it will give me: 2. That is at some point I will need two people.
If I filter by only 1 January in the morning, it will return: 1, as in one person max needed.
In my mind is getting a MAXX that will be applied to a table, counting the rows and grouping dates and schedule. But don't know how.
Thanks in advance!
Solved! Go to Solution.
At the end I combined MAXX, SUMMARIZE and DISTINCTCOUNT
At the end I combined MAXX, SUMMARIZE and DISTINCTCOUNT
The above is almost what I wanted. My mistake, it has to count distinct (I wish there was a COUNTDISTINCTX). For example at the bottom, for Day 01/01/2021 and Morning, it's two unique people.
Person | Day | Schedule |
John | 01/01/2021 | Morning |
Esther | 02/01/2021 | Evening |
Maria | 01/01/2021 | Morning |
Pedro | 01/01/2021 | Evening |
John | 02/01/2021 | Morning |
John | 01/01/2021 | Morning |
Any ideas?
Hi @Anonymous ,
Create two measures.
Measure =
CALCULATE (
DISTINCTCOUNT ( 'Table'[Person] ),
ALLEXCEPT ( 'Table', 'Table'[Day], 'Table'[Schedule] )
)
Measure 3 = MAXX('Table',[Measure])
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Anonymous Are you sure that you meant 1 January and not 2 January is when you need 2 people? Because...the data...
In any case, I think what you want is:
Measure =
VAR __Table = GROUPBY('Table',[Day],[Schedule],"__Count",COUNTX(CURRENTGROUP(),[Person]))
RETURN
MAXX(__Table,[__Count])
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
115 | |
100 | |
88 | |
68 | |
61 |
User | Count |
---|---|
150 | |
120 | |
100 | |
87 | |
68 |