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
harshadsp
Post Patron
Post Patron

DAX for MIn/Max based on count

Hello All, Need hep!

 

I need to dispay (on card tile) min and max hour when the count of crime is min and max. Hour is on x axis and crime # on y axis. In this example I need to dispay max time as 2am since count is 170 and min time 20.00 since min crime is 24 on that time.

 

Capture.PNG

 

Could you please advise how do I achieve this? I am thinking to make a column using DAX but not sure the formula in DAX.

 

Thanks!

1 ACCEPTED SOLUTION

Hi @harshadsp

 

Check this file here

 

Try this

Time_MaxCrime =
VAR MaxCount =
    MAXX ( VALUES ( Table1[Time] ), CALCULATE ( COUNT ( Table1[Crime Type] ) ) )
RETURN
    CALCULATE (
        CONCATENATEX (
            FILTER (
                VALUES ( Table1[Time] ),
                CALCULATE ( COUNT ( Table1[Crime Type] ) = MaxCount )
            ),
            Table1[Time]
        )
    )

Regards
Zubair

Please try my custom visuals

View solution in original post

21 REPLIES 21

HI @harshadsp

 

Another way, in case there are'nt more than 1 time with same Count of Maximum Crimes

 

TimeMaxCrime =
VAR MaxCount =
    MAXX ( VALUES ( Table1[Time] ), CALCULATE ( COUNT ( Table1[Crime Type] ) ) )
RETURN
    CALCULATE (
        VALUES ( Table1[Time] ),
        FILTER (
            VALUES ( Table1[Time] ),
            CALCULATE ( COUNT ( Table1[Crime Type] ) = MaxCount )
        )
    )

Regards
Zubair

Please try my custom visuals

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.