Forum Discussion
SUMX with calculate average
Hello
I need apply this function
I created a simple datatable
AVGx = AVERAGE(Table1[x])
Measure Manual = SUMX(Table1; Table1[x] - 14)
Measure Calc = SUMX(Table1;(Table1[x] - [AVGx]))
Mesaure Manual is my desired result and Measure Calc is my automated measure
The problem is in Measure Calc this caculate the average per each row and is the same wth x and the result is 0 normal!, i need to calculalte the average total in the context filter (Cliente = C1) --> 14
Thanks
Hello sebasjun
Try this - storing the average in a variable. Previously when the [AVGx] measure was computed in the context of each row, context transition meant that it was just averaging the value on that row.
Measure Calc = VAR Avg = [AVGx] RETURN SUMX ( Table1; ( Table1[x] - Avg ) )
I think the average has to be either with ALL or ALLSELECTED
AVGx:=CALCULATE(AVERAGE(Table1[x]),ALLSELECTED(Table1[x]))
5 Replies
- OwenAuger
Super User
Hello sebasjun
Try this - storing the average in a variable. Previously when the [AVGx] measure was computed in the context of each row, context transition meant that it was just averaging the value on that row.
Measure Calc = VAR Avg = [AVGx] RETURN SUMX ( Table1; ( Table1[x] - Avg ) )
- v-yuta-msft
Community Support
Hi sebasjun,
Change measure [AVGx] to a calculate column [AVGx Column] them modify [Measure Calc] using DAX like this:
Measure Calc = VAR XXX = MAX(Table1[AVGx Column]) RETURN SUMX ( Table1, ( Table1[x] - XXX ) )
The result is as below:
Regards,
Jimmy Tao