Forum Discussion
Creating a sum based on averages
- Anonymous4 years ago
Hi rjaramillo ,
I think there are two kinds of ways to create measures to calculate correct average total.
Measure1:
Measure 2 = SUMX(VALUES('Table'[subcategory]),CALCULATE( AVERAGE('Table'[cost])))You need to add "CALCULATE" function before "AVERAGE", it will consider filter context and give you correct result.
Measure2:
Measure1 = VAR _SUMMARIZE = SUMMARIZE('Table','Table'[subcategory],"Avg by subcategory",CALCULATE(AVERAGE('Table'[cost]))) RETURN SUMX(_SUMMARIZE,[Avg by subcategory])Result is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi rjaramillo ,
I think there are two kinds of ways to create measures to calculate correct average total.
Measure1:
Measure 2 =
SUMX(VALUES('Table'[subcategory]),CALCULATE( AVERAGE('Table'[cost])))
You need to add "CALCULATE" function before "AVERAGE", it will consider filter context and give you correct result.
Measure2:
Measure1 =
VAR _SUMMARIZE = SUMMARIZE('Table','Table'[subcategory],"Avg by subcategory",CALCULATE(AVERAGE('Table'[cost])))
RETURN
SUMX(_SUMMARIZE,[Avg by subcategory])
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
the CALCULATE part is what I was missing! Thank you so much!