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
Anonymous
Not applicable

Need a dax formula to get the max count in a grouping

Hello!

 

I have the below table, and what I need, for a period, the max number of people on a day. For example:

 

PersonDaySchedule
John01/01/2021Morning
Esther02/01/2021Evening
Maria01/01/2021Morning
Pedro01/01/2021Evening
John02/01/2021Morning

 

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!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

At the end I combined MAXX, SUMMARIZE and DISTINCTCOUNT

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

At the end I combined MAXX, SUMMARIZE and DISTINCTCOUNT

Anonymous
Not applicable

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.

 

PersonDaySchedule
John01/01/2021Morning
Esther02/01/2021Evening
Maria01/01/2021Morning
Pedro01/01/2021Evening
John02/01/2021Morning
John01/01/2021Morning

 

Any ideas?

Icey
Community Support
Community Support

Hi @Anonymous ,

 

Create two measures.

Measure = 
CALCULATE (
    DISTINCTCOUNT ( 'Table'[Person] ),
    ALLEXCEPT ( 'Table', 'Table'[Day], 'Table'[Schedule] )
)
Measure 3 = MAXX('Table',[Measure])

count.gif

 

 

Best Regards,

Icey

 

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

Greg_Deckler
Community Champion
Community Champion

@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])


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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

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