Forum Discussion

am-person's avatar
am-person
Regular Visitor
2 years ago
Solved

Subtracting Averages from a table across columns

I'm wrecking my brain trying to figure out something that seems simple.  I have a data set that has a group of teams from which I have generated a measure for the team Avg that I can display in the f...
  • parry2k's avatar
    2 years ago

    am-person I could be wrong but this is what I think the result should be:

     

    Avg = AVERAGE ( 'Team'[pts] )
    
    Team Avg = 
    CALCULATE (
        [Avg],
        ALLSELECTED ( 'Team'[opponent] )
    )
    
    Avg Diff = 
    VAR vTeamAvg =
        [Team Avg]
    VAR vOpponentAvg =
        CALCULATE (
            [Team Avg],
            ALL ( 'Team'  ),
            TREATAS ( VALUES ( 'Team'[Opponent] ), 'Team'[Team] )
        )
    VAR vResult = vTeamAvg - vOpponentAvg
    RETURN
        vResult