Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Maestro
Frequent Visitor

Sum of maximal value for specific name

Moving from (pivot)tables in Excel to Power BI provides some struggles. I will try to show my struggle as detailed as needed. The case: as a KPI (Key Performance Indicator) in sports I need to know from longitudinal data IF a player passed the benchmark or not (providing a % by dividing passed/all cases). He only needs to pass the benchmark once during the year (multiple matches obviously; benchmark can be different depending on playing position).

 

NameMatchTotal distance covered (m)Benchmark (m)Passed (o=no;1=yes)
Player A1600050001
Player B1400050000
Player C1700060001
Player D0 **1500--
Player A2550050001
Player B2400050000
Player C2500060000

** not enough playtime, so data is there, but not included for the KPI.

 

KPI = passed/total

In Excel I would insert a Pivot table on the table above and then use "Max of passed" providing for each player if he ever passed the benchmark and total amount of filled cells (so unique players in this pivot table). The pivot table in this example would look like:

NameMax of passed
Player A1
Player B0
Player C1

KPI: 2 out of 3=66.7%

Player D is not included in pivot table, since there is no valid data (0 or 1) Sum of Max of passed is needed, since 'just' sum of passed will provide 2 instead of 1 for player 1. 

 

In Power BI I provided a new measure  "amount_players" which is: DISTINCTCOUNT(query1[player]). This will show the amount of players that pass multiple filters (minimum of playing time, team and season). Now I need a measure "amount_passed" but using MAX(X), SUM or a combination does not deliver the right answer. The main struggle appears when a player is able to pass the benchmark for 3 matches; any use of sum wants to enter the player with a '3', but I only want to count him once. 

 

If I need to provide more context or sample data, please let me know! 

2 ACCEPTED SOLUTIONS
VahidDM
Super User
Super User

Hi @Maestro 

 

Please try this measure: [Edited]

 

amount_passed =
COUNTROWS (
    SUMMARIZE (
        FILTER ( 'Table', 'Table'[Passed] = 1 ),
        'Table'[Name],
        "pass", MAX ( 'Table'[Passed] )
    )
)

 

 

Did I answer your question? Mark my post as a solution!

Appreciate your Kudos VahidDM_0-1630033994438.png !!

View solution in original post

Thanks for your quick response @VahidDM. It does not work yet; the error (MdxScript(model)(10,80) that in the DAX formula they can't  compare Integer (pass yes, no or empty) with Text/String (player name). They suggest to use the VALUE or FORMAT function, but that would only work if I replace Name by a ID-number. Any suggestions to make it work while still using the playernames as strings? 

 

EDIT: it worked, after replacing the "1" with 1 as boolean expression within the FILTER: 

FILTER ( 'Table', 'Table'[Passed] = 1 ),

 Thanks!

View solution in original post

3 REPLIES 3
VahidDM
Super User
Super User

Hi @Maestro 

 

Please try this measure: [Edited]

 

amount_passed =
COUNTROWS (
    SUMMARIZE (
        FILTER ( 'Table', 'Table'[Passed] = 1 ),
        'Table'[Name],
        "pass", MAX ( 'Table'[Passed] )
    )
)

 

 

Did I answer your question? Mark my post as a solution!

Appreciate your Kudos VahidDM_0-1630033994438.png !!

Thanks for your quick response @VahidDM. It does not work yet; the error (MdxScript(model)(10,80) that in the DAX formula they can't  compare Integer (pass yes, no or empty) with Text/String (player name). They suggest to use the VALUE or FORMAT function, but that would only work if I replace Name by a ID-number. Any suggestions to make it work while still using the playernames as strings? 

 

EDIT: it worked, after replacing the "1" with 1 as boolean expression within the FILTER: 

FILTER ( 'Table', 'Table'[Passed] = 1 ),

 Thanks!

Happy to see you sorted it out. VahidDM_0-1630485682084.png !!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.