Forum Discussion
Team share % measure (based on variable) changes in scatterplot to total of all rows
- 10 months ago
Rather than using ALLEXCEPT you can use REMOVEFILTERS and VALUES, e.g.
Team Share % = VAR PlayerPoints = CALCULATE ( SUM ( 'Table'[Points] ) ) VAR TeamPoints = CALCULATE ( SUM ( 'Table'[Points] ), REMOVEFILTERS ( 'Table' ), VALUES ( 'Table'[Team] ) ) RETURN DIVIDE ( PlayerPoints, TeamPoints )There's articles about this technique at https://www.sqlbi.com/articles/using-allexcept-versus-all-and-values/ and https://www.sqlbi.com/articles/using-allexcept-vs-all-values/
- 10 months ago
Hi FPE5,
You’re seeing that because your measure removes all filters except Team, and on the scatter the Team column isn’t on the visual. That means your “team total” quietly becomes the grand total (all Names), so Pete’s share turns into 5/30 instead of 5/20.
Here’s a robust pattern that always re-applies the player’s Team and only removes the Name filter when computing the team total (so page/report filters like Date still apply).
Team Share % := VAR TeamForName = SELECTEDVALUE('Table'[Team]) VAR PlayerPoints = SUM('Table'[Points]) VAR TeamPoints = CALCULATE( SUM('Table'[Points]), REMOVEFILTERS('Table'[Name]), -- ignore the current Name only KEEPFILTERS('Table'[Team] = TeamForName) -- force the player’s Team ) RETURN IF ( NOT ISBLANK(TeamForName), DIVIDE(PlayerPoints, TeamPoints) )Use that measure on your scatter (X or Y), with Name as the category/detail. It will return 25% for Pete even if Team isn’t on the visual.
If you found this helpful, consider giving some Kudos. If I answered your question or solved your problem, mark this post as the solution.
Rather than using ALLEXCEPT you can use REMOVEFILTERS and VALUES, e.g.
Team Share % =
VAR PlayerPoints =
CALCULATE ( SUM ( 'Table'[Points] ) )
VAR TeamPoints =
CALCULATE (
SUM ( 'Table'[Points] ),
REMOVEFILTERS ( 'Table' ),
VALUES ( 'Table'[Team] )
)
RETURN
DIVIDE ( PlayerPoints, TeamPoints )
There's articles about this technique at https://www.sqlbi.com/articles/using-allexcept-versus-all-and-values/ and https://www.sqlbi.com/articles/using-allexcept-vs-all-values/
- FPE510 months agoRegular Visitor
Thank you, John!
This worked like a charm.Thanks aswell for the two links, im gonna dive into these 🙂