Forum Discussion
alfertab
2 years agoHelper I
SUMX using Max
Hi, everyone, I've been having troubles with my total POWER BI code and I would like to know if you could help me. My problem is that in the subtotals I am looking to add (using SUMX) the maximums d...
- 2 years ago
The reason you get the wrong total days is because the SUMX is iterating over all days in your table, rather than just the two seasons. You can try something like the following:
MAX = IF (HASONEVALUE ( 'Table'[Season]), MAX('Table'[MAX Daily]), SUMX( ADDCOLUMNS( SUMMARIZE('Table', 'Table'[Season]), "season max", CALCULATE(MAX('Table'[MAX Daily])), "days", CALCULATE(COUNTROWS('Table')) ), [season max] * [days] ))
vicky_
2 years agoSuper User
The reason you get the wrong total days is because the SUMX is iterating over all days in your table, rather than just the two seasons. You can try something like the following:
MAX = IF (HASONEVALUE (
'Table'[Season]),
MAX('Table'[MAX Daily]),
SUMX(
ADDCOLUMNS(
SUMMARIZE('Table', 'Table'[Season]),
"season max", CALCULATE(MAX('Table'[MAX Daily])),
"days", CALCULATE(COUNTROWS('Table'))
), [season max] * [days]
))
- alfertab2 years agoHelper I
¡Thanks a lot! It was very helpfull 😃