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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
candeezymac
New Member

CALCULATE and Filter context

I am trying to learn to work with CALCULATE to modify filter contexts in my reports but really struggling. I have created this simple example to see if I can get some help with this basic question. 

 

My data is simply as follows... 6 players on 3 different teams scoring goals.

PlayerTeamGameGoals
ANY12
ANY24
BFLA11
BFLA23
BFLA31
CDET11
CDET22
DNY11
DNY22
EFLA13
EFLA21
EFLA31
FDET21
FDET32

 

If I want to sum Player A's goals across all games, it is simply, 

 

PlayerGoals = SUM('Table'[Goals])

 

This correctly returns 6.

 

If I want to sum all of Team NY's goals, it is simply, 

 

TeamGoals = CALCULATE(SUM('Table'[Goals]), FILTER('Table','Table'[Team]="NY"))

 

This correctly returns 9 (i.e. the sum of player A's goals and player D's goals!).

 

So then, why is the share of goals for player A not returning correctly when I try,

 

%Share_of_Team_Goals = DIVIDE(
    SUM('Table'[Goals]),
        CALCULATE(SUM('Table'[Goals]), FILTER('Table','Table'[Team]="NY")
        )
    )

 

*If I have a slicer selecting player "A", this returns 100%, because 6 goals is 100% of player A's goals. If I remove the slicer, it returns 278%, because the goals for all players are 2.78x the goals for NY players. 

 

What I want to return is 66% for player A, but the measure should work dynamically regardless of which player I select. 

 

Anyone have any tips for me? I've been tinkering with all sorts of ALL() and KEEPFILTERS() and REMOVEFILTERS() and I'm really just stuck in a loop. Please help!

 

1 ACCEPTED SOLUTION
ThxAlot
Super User
Super User

Goal.pbix

 

ThxAlot_0-1691307524082.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



View solution in original post

4 REPLIES 4
ThxAlot
Super User
Super User

Goal.pbix

 

ThxAlot_0-1691307524082.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



I'm speechless; Thank you! The VALUES() function is something I did not come across in my research but it makes so much sense (hindsight being 20/20) because DAX needs to know the "value" of the team that the player is on. Eureka!

Anonymous
Not applicable

Hi,
Your Output part is confusing to me, can you elaborate a bit the output part or if you can showcase the output values in excel, it will works

Are you looking for below result.

anilkapkoti_0-1691305608090.png

 

This is it yes, but it needs to work for any player/ team! Above solution only works for NY. I think that @ThxAlot solved it in his post! Thanks for your response and support!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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