Forum Discussion
Calculating Cumulative total of average using DAX expression
- Anonymous8 years ago
Hi Anonymous,
After play with your data, I create a measure to calculate cumulative average:
Measure = VAR currYear = MAX ( OVC_data[OVC_YEAR] ) RETURN SUMX ( FILTER ( SUMMARIZE ( ALLSELECTED ( OVC_data ), [OVC_YEAR], "Total Value", SUM ( OVC_data[OVC_Value] ), "AVG Value", AVERAGE ( OVC_data[OVC_Value] ) ), [OVC_YEAR] <= currYear ), [AVG Value] )Regards,
Xiaoxin Sheng
HI Anonymous,
You can try to use below column formula to get cumulative average value from summary table.
Column formula:
Calculate column =
SUMX (
FILTER (
SUMMARIZE (
Table,
[Year],
"Total Value", SUM ( Table[OVC_Value] ),
"AVG Value", AVERAGE ( Table[OVC_Value] )
),
[Year] <= Table[Year]
),
[AVG Value]
)
If above not help, please share some sample data for test and coding formula.
Regards,
Xiaoxin Sheng
Hi Xiaoxin Sheng,
I tried the given solution but it did not work because i belive that while adding cumulative average it is also adding the cumulative counts of values and as a result the cumulative average keeps in decreasing, i am attaching the database, thank you very much for helping me on this...
Regards,
Malav
- Anonymous8 years agoNot applicable
Hi Anonymous,
After play with your data, I create a measure to calculate cumulative average:
Measure = VAR currYear = MAX ( OVC_data[OVC_YEAR] ) RETURN SUMX ( FILTER ( SUMMARIZE ( ALLSELECTED ( OVC_data ), [OVC_YEAR], "Total Value", SUM ( OVC_data[OVC_Value] ), "AVG Value", AVERAGE ( OVC_data[OVC_Value] ) ), [OVC_YEAR] <= currYear ), [AVG Value] )Regards,
Xiaoxin Sheng