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
Creative_tree88
Helper III
Helper III

MAX Count of Date Measure

Hi - I have the following date (abbreviated sample).  I count by Event Key (table is called 'WBR').  I'd like to produce a measure which calculates the highest maximum count, across all the dates.  I'd then like to somehow display the Date, to which this maximum count occurs on.

In my sample, the Maximum count (based on Event Key) is 6, and this occured on 01/01/2022.

Really appreciate your help on what it probably quite simple but it's tying me up in knots at the moment!  Many thanks everyone.

Event KeyStat Date
443211901/01/2022
479890401/01/2022
542679601/01/2022
548309002/02/2022
528989702/03/2022
424542902/03/2022
436655004/01/2022
731769005/01/2022
449497306/01/2022
656046807/01/2022
472233408/01/2022
577013109/03/2022
532304010/02/2022
603342001/01/2022
521018801/01/2022
436436701/01/2022
1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Creative_tree88 

 

You can try the following methods.
Measure:

Count = CALCULATE(COUNT('Table'[Stat Date]),ALLEXCEPT('Table','Table'[Stat Date]))
Max Count = MAXX(ALL('Table'),[Count])
Max Count Date = CALCULATE(MAX('Table'[Stat Date]),FILTER(ALL('Table'),[Count]=[Max Count]))

vzhangti_0-1678772929864.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

6 REPLIES 6
v-zhangti
Community Support
Community Support

Hi, @Creative_tree88 

 

You can try the following methods.
Measure:

Count = CALCULATE(COUNT('Table'[Stat Date]),ALLEXCEPT('Table','Table'[Stat Date]))
Max Count = MAXX(ALL('Table'),[Count])
Max Count Date = CALCULATE(MAX('Table'[Stat Date]),FILTER(ALL('Table'),[Count]=[Max Count]))

vzhangti_0-1678772929864.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

 

YukiK
Impactful Individual
Impactful Individual

 

MAXX(
    VALUES('WBR'[Stat Date]),
    CALCULATE( COUNTROWS('WBR') )
)

 

 

Give it a thumbs up and accept as solution if this is helpful!

@YukiK  - that works.  But how do I create a second measure to show me the date that this MAX corresponds to?  In my example above it would be 01/01/2022.  Many thanks!

Your Measure = 
VAR _Cnt = CALCULATE( COUNTROWS('WBR') )
VAR _MaxDate = 
FILTER(
    VALUES('WBR'[Stat Date]),
    CALCULATE( COUNTROWS('WBR') ) = _Cnt
)
RETURN
_MaxDate

 

This should work, though, I'd have "COUNTROWS('WBR')" as a separate measure and reference it in other measures.

 

 

@YukiK  - this doesn't seem to work.  Power BI doesn't return any date, just 'Blank'. Any ideas?

Oops. I just referenced a wrong thing. Replace the first variable with this one:

VAR _Cnt = [Max Cnt Measure you just created]

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.