Forum Discussion
Wrong Sub-Total when calculating Avg
- 2 years ago
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.
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
Hello,
Thanks for your reply,
But I don't really know,how change I need to make?
- Anonymous2 years agoNot 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.