Forum Discussion
itchyeyeballs
9 years agoImpactful Individual
SumX using max
Hi all,
I'm having an issue with using SumX and can't figure out what I'm doing wrong (the 'X' functions always trip me up)
I'm trying to calculate the sum of the maximum values accross groups.
My formula is
=if(HASONEVALUE(Table1[col2]), max(Table1[Value]), sumx(values(Table1[col2]),max(table1[value])) )
The results look like
The third grand total is showing 30 rather than 16, it seems like my sumx is using 15 twice rather than 15 + 1. Any ideas where I'm going wrong?
Thanks
hi, just add a Calculate in Max.
Measure 2 = IF ( HASONEVALUE ( Table1[col2] ), MAX ( Table1[Value] ), SUMX ( VALUES ( Table1[Col2] ), CALCULATE ( MAX ( table1[value] ) ) ) )
3 Replies
- VvelardeCommunity Champion
hi, just add a Calculate in Max.
Measure 2 = IF ( HASONEVALUE ( Table1[col2] ), MAX ( Table1[Value] ), SUMX ( VALUES ( Table1[Col2] ), CALCULATE ( MAX ( table1[value] ) ) ) )- itchyeyeballsImpactful Individual
Perfect, thank you!
- OwenAugerSuper User
A side note:
You can also get rid of the HASONEVALUE test, since if Col2 has one value then SUMX will iterate over that one value anyway:
= SUMX ( VALUES ( Table1[Col2] ), CALCULATE ( MAX ( table1[value] ) ) )