Forum Discussion
Wrong Sub-Total when calculating Avg
Hi Experts
I have two measure both are calculating Average Ratio,
but when using in pivot, they have different result in Sub-Total
Ideal sub-total I want is AVG, not SUM
I have try so many solution but can't fix it,
please help me.
Correct
A Column=>
Wrong
B Column=>
Hi Lily36876
Your average is computed at the total level by dividing the total 'DAX Table'[Store_Bouns] over total SUM('SalesData'[HSlTot]. If you want the average to evaluated based on the rows in your matrix, try:
AVERAGEX ( VALUES ( 'table'[name of row column in the matrix] ), [divide measure] )If this doesn't work, please provide a workable sample data (not an imate) and your expected result from that sample data. Please refer to this sticky post https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/td-p/1447523/jump-to/first-unread-message
- Anonymous2 years ago
Hi Lily36876 ,
danextian Thanks for your concern about this case!
I will give you an example to explain what does danextian mean. Here is the sample data:I use this DAX to create a measure:
Measure = DIVIDE(SUM('Table'[Actual]), SUM('Table'[Expected]))And the output is as below:
And the total here is calculated as below:
(12+16+13+18+19+22+17+11+9+16)/(15+20+10+15+20+20+15+10+10+15)=1.02That is, the sum of the Actual column divided by the sum of the Expected column, rather than the average of all measure results. That's what danextian meant by “Your average is computed at the total level by dividing the total 'DAX Table'[Store_Bouns] over total SUM('SalesData'[HSlTot])”.
Then I use this DAX to add a measure:Measure 2 = IF( ISFILTERED('Table'[Index]), [Measure], AVERAGEX(VALUES('Table'[Index]), [Measure]) )And the output is as below:
And the total here is calculating the average of all measure results:
(0.8+0.8+1.3+1.2+0.95+1.1+1.133+1.1+0.9+1.067)/10=1.035This is what you want.
Best Regards,
Dino Tao
If this post helps, then please consider Accept both of the answers as the solution to help the other members find it more quickly.
3 Replies
- danextianSuper User
Hi Lily36876
Your average is computed at the total level by dividing the total 'DAX Table'[Store_Bouns] over total SUM('SalesData'[HSlTot]. If you want the average to evaluated based on the rows in your matrix, try:
AVERAGEX ( VALUES ( 'table'[name of row column in the matrix] ), [divide measure] )If this doesn't work, please provide a workable sample data (not an imate) and your expected result from that sample data. Please refer to this sticky post https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/td-p/1447523/jump-to/first-unread-message
- Lily36876Helper II
Hello,
Thanks for your reply,
But I don't really know,how change I need to make?
- AnonymousNot applicable
Hi Lily36876 ,
danextian Thanks for your concern about this case!
I will give you an example to explain what does danextian mean. Here is the sample data:I use this DAX to create a measure:
Measure = DIVIDE(SUM('Table'[Actual]), SUM('Table'[Expected]))And the output is as below:
And the total here is calculated as below:
(12+16+13+18+19+22+17+11+9+16)/(15+20+10+15+20+20+15+10+10+15)=1.02That is, the sum of the Actual column divided by the sum of the Expected column, rather than the average of all measure results. That's what danextian meant by “Your average is computed at the total level by dividing the total 'DAX Table'[Store_Bouns] over total SUM('SalesData'[HSlTot])”.
Then I use this DAX to add a measure:Measure 2 = IF( ISFILTERED('Table'[Index]), [Measure], AVERAGEX(VALUES('Table'[Index]), [Measure]) )And the output is as below:
And the total here is calculating the average of all measure results:
(0.8+0.8+1.3+1.2+0.95+1.1+1.133+1.1+0.9+1.067)/10=1.035This is what you want.
Best Regards,
Dino Tao
If this post helps, then please consider Accept both of the answers as the solution to help the other members find it more quickly.