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
ajinkya1907
Helper II
Helper II

DAX function related Issue

Hi,

 

I am using Cricket related data for one of my report. I would like to find out Maximum Strike Rate batsmans with more than 100 runs.  I am using below formula

 

Best Strike Rate =
var temp = FILTER(
SUMMARIZE(deliveries,
deliveries[match_id],
deliveries[Batsman],
"StrikeRate", 100* SUM(deliveries[batsman_runs])/COUNT(deliveries[Batsman])
),SUM(deliveries[batsman_runs]) >= 100)
return
MAXX(temp, [StrikeRate])

 

 

It's showing total strike rate & not the max stike rate. Kindly advise. Attached screenshot for your reference.

 

Capture.JPG

 

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

Hi @ajinkya1907

 

How about this one?

 

Best Strike Rate =
VAR temp =
    FILTER (
        SUMMARIZE (
            deliveries,
            deliveries[match_id],
            deliveries[Batsman],
            "StrikeRate", 100 * SUM ( deliveries[batsman_runs] )
                / COUNT ( deliveries[Batsman] )
        ),
        CALCULATE ( SUM ( deliveries[batsman_runs] ) ) >= 100
    )
RETURN
    MAXX ( temp, [StrikeRate] )

Regards
Zubair

Please try my custom visuals

View solution in original post

3 REPLIES 3
Zubair_Muhammad
Community Champion
Community Champion

Hi @ajinkya1907

 

How about this one?

 

Best Strike Rate =
VAR temp =
    FILTER (
        SUMMARIZE (
            deliveries,
            deliveries[match_id],
            deliveries[Batsman],
            "StrikeRate", 100 * SUM ( deliveries[batsman_runs] )
                / COUNT ( deliveries[Batsman] )
        ),
        CALCULATE ( SUM ( deliveries[batsman_runs] ) ) >= 100
    )
RETURN
    MAXX ( temp, [StrikeRate] )

Regards
Zubair

Please try my custom visuals

Well That works just fine. @Zubair_Muhammad, I am your fan buddy.

 

Could you please explain why calculate function made the difference? I am not able to understand that part. 

Hi @ajinkya1907

 

Wow I have 2 fans now... Other is my 3 year old son

 

Actually FILTER function is an ITERATOR.... it creates a ROW context and not a FILTER context

 

thats why you have to use Calculate


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.