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
Fabio74
Helper I
Helper I

Sum Values with multiple filters and a "condition"

Hi everyone, I hope my question doesn't already have an aswer. I've tried to search in other posts but, since I'm new to PowerBi, I'm not very good at adapting possible solutions for cases similar to mine.  If that's the case, I apologize in advance.

I was trying to come up with a formula (possibly a measure but I'm starting with a column because it's easier for me to evaluate the results) to calculate the contribution of points (in %) for each player to the total of points of each team. 

Here's my sample table:

 

Day Nr.TeamPlayerNameVotePlayedTot Points * Team * Day% * Player * Team
Day 1Team APlayer 16Yes666,57%
Day 2Team APlayer 16Yes686,57%
Day 3Team APlayer 15,5Yes716,57%
Day 4Team APlayer 10No556,57%
Day 5Team APlayer 10No886,57%
Day 6Team APlayer 19,5Yes726,57%
Day 7Team APlayer 110Yes776,57%
Day 8Team APlayer 111No666,57%
Day 9Team BPlayer 10No590,00%
Day 10Team BPlayer 10No630,00%
Day 11Team BPlayer 10No870,00%
Day 12Team BPlayer 10No720,00%
Day 13Team BPlayer 10No650,00%
Day 14Team BPlayer 10No680,00%
Day 15Team BPlayer 10No820,00%
Day 16Team BPlayer 10No700,00%


As I want to consider the vote of the player only when he actually contributed to the total score of the team (when he played), I need to filter by name of the player, by team and when "Played" is "yes".

In Excel (the result is in the last column of the above table) it would be something as simple as this 

 

=SUMIFS([Vote];[Team];[@Team];[Played];"Yes";[PlayerName];[@PlayerName])/SUMIFS([Tot Points * Team * Day];[Team];[@Team])

 

but in DAX I'm struggling with the played/not played part.
I came up first with the following formula 

 

% P * Player = CALCULATE(SUM(Table1[Vote]), ALLEXCEPT(Table1, Table1[Player], Table1[Team])))/ CALCULATE(SUM(Table1[Tot Points * Team * Day]), ALLEXCEPT(Table1, Table1[Team]))

 

but since it doesn't take into account the filter on the "Played" field, the result is not what I'd like (for Team A takes into account the vote of Player 1 for Day 8 when he was not put in the line-up by the Manager).
I've tried to add an additional filter to the previous formula

 

% P * Player = CALCULATE(SUM(Table1[Vote]), FILTER(Table1, Table1[Played] = "Yes"), ALLEXCEPT(Table1, Table1[Player], Table1[Team])))/ CALCULATE(SUM(Table1[Tot Points * Team * Day]), ALLEXCEPT(Table1, Table1[Team]))

 

but the result is even worse (much worse - complete "nonsense" in respect of the desiderd outcome).

I think I'm not very far from obtaining the desidered result, but the syntax (or my faulty logic possibly) is killing me ... XD

Can somebody please point me in the right direction?

 

Thanks in advance.

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

You don't look too far off but one thing you may not realize is that where you have FILTER(Table1, Table1[Played] = "Yes"), the table, Table1, is evaluated within the local filter context rather than representing the entire table. The FILTER function adds additional filters but Table1 is already filtered by Day, Team, Player, Played etc. and you are adding another filter. What you actually intend is to apply this condition to the less filtered version of the table:

 

FILTER ( ALLEXCEPT ( Table1, Table1[Player], Table1[Team] ), Table1[Played] = "Yes" )

 

This is a bit ugly, so I'd suggest this instead:

 

% P * Player =
DIVIDE (
    CALCULATE (
        SUM ( Table1[Vote] ),
        Table1[Played] = "Yes",
        ALLEXCEPT ( Table1, Table1[Player], Table1[Team] )
    ),
    CALCULATE (
        SUM ( Table1[Tot Points * Team * Day] ),
        ALLEXCEPT ( Table1, Table1[Team] )
    )
)

 

Note that the boolean condition Table1[Played] = "Yes" is equivalent to FILTER ( ALL ( Table1[Played] ), Table1[Played] = "Yes" ) but easier to read.

 

View solution in original post

2 REPLIES 2
AlexisOlson
Super User
Super User

You don't look too far off but one thing you may not realize is that where you have FILTER(Table1, Table1[Played] = "Yes"), the table, Table1, is evaluated within the local filter context rather than representing the entire table. The FILTER function adds additional filters but Table1 is already filtered by Day, Team, Player, Played etc. and you are adding another filter. What you actually intend is to apply this condition to the less filtered version of the table:

 

FILTER ( ALLEXCEPT ( Table1, Table1[Player], Table1[Team] ), Table1[Played] = "Yes" )

 

This is a bit ugly, so I'd suggest this instead:

 

% P * Player =
DIVIDE (
    CALCULATE (
        SUM ( Table1[Vote] ),
        Table1[Played] = "Yes",
        ALLEXCEPT ( Table1, Table1[Player], Table1[Team] )
    ),
    CALCULATE (
        SUM ( Table1[Tot Points * Team * Day] ),
        ALLEXCEPT ( Table1, Table1[Team] )
    )
)

 

Note that the boolean condition Table1[Played] = "Yes" is equivalent to FILTER ( ALL ( Table1[Played] ), Table1[Played] = "Yes" ) but easier to read.

 

Thank you very much @AlexisOlson , also for taking the extra time to explain, which is much appreciated. You are absolutely right about the clarity of your second formula. Not really knowing what I'm doing I have a tendency to "add layers" instead, trying to replicate Excel 😄

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