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
Anonymous
Not applicable

Measure to calculate opposite value?

My simplified data looks like this:

 

Data Ex.jpg

 

The first table ("Player List") is connected to the second table ("Player Stats") by Player Name. I have a simple measure that sums stats in table "Player Stats".

 

So in my table visual, I could show Team from the "Player List" table with my measure and get NYY = 10 and WSH = 2.

 

How would I be able to flip this measure around so that when NYY is displayed on the table visual it sums the measure based on that team's opponent (WSH) rather than the team listed in the table. So the result would be flipped for the proposed measure. NYY would = 2 and WSH would = 10.

 

My attempted measure is this, but it returns blank:

 

Opp Measure = VAR Opp = MAX('Player List'[Opponent]) RETURN CALCULATE([Measure],ALL('Player List'),FILTER('Player List','Player List'[Team]= Opp))

  

1 ACCEPTED SOLUTION
V-pazhen-msft
Community Support
Community Support

@Anonymous 

Maybe provide a visual explain of your expected output, I am a bit unsure about your demand. For the measure, try:

 

Opp Measure = CALCULATE([Measure],FILTER(ALL('Player List'),'Player List'[Team]= MAX('Player List'[Opponent])))

 

 

Paul Zheng _ Community Support Team
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
V-pazhen-msft
Community Support
Community Support

@Anonymous 

Maybe provide a visual explain of your expected output, I am a bit unsure about your demand. For the measure, try:

 

Opp Measure = CALCULATE([Measure],FILTER(ALL('Player List'),'Player List'[Team]= MAX('Player List'[Opponent])))

 

 

Paul Zheng _ Community Support Team
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Greg_Deckler
Super User
Super User

@Anonymous - Here is one way:

Measure 2 = 
    VAR __Opp = MAX('Player List'[Opponent])
    VAR __Opponents = SELECTCOLUMNS(FILTER(ALL('Player List'),[Opponent] = __Opp),"Player",[Player])
RETURN
    SUMX(FILTER(ALL('Player Stats'),NOT([Player] IN __Opponents)),[Stats])

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler Thanks for the reply. I simplified my data in the example. I think I understand your formula, but I think it is producing a higher than expected value, because there are more than just two teams in the dataset. 

 

I think your formula is saying to sum up everything else if it's not the other. Which in my dataset is a lot more teams since there are more than 2. I could be wrong, but I think that's it.

@Anonymous - Well, it is grabbing the MAX opponent in context. I don't know what context that might be or how you want it to work if there are multiple opponents. What do you want to do if there are multiple opponents in context?

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.