Forum Discussion
am-person
2 years agoRegular Visitor
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...
- 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
parry2k
Super User
2 years agoam-person could you share what your raw data looks like and also what measures you are using for average?
am-person
2 years agoRegular Visitor
Raw data file is rather large but here's the gist of it:
| game | team | opponent | pts |
| 1 | A | X | 1 |
| 1 | B | Y | 2 |
| 1 | C | Z | 3 |
| 1 | X | A | 4 |
| 1 | Y | B | 5 |
| 1 | Z | C | 6 |
| 2 | A | Y | 7 |
| 2 | B | Z | 8 |
| 2 | C | X | 9 |
| 2 | X | C | 10 |
| 2 | Y | A | 1 |
| 2 | Z | B | 2 |
| 3 | A | Z | 3 |
| 3 | B | X | 4 |
| 3 | C | Y | 5 |
| 3 | X | B | 6 |
| 3 | Y | C | 7 |
| 3 | Z | A | 8 |
I am using a measure:
Team Avg = AVERAGE('Table'[pts])