Forum Discussion
Need help with calculating row variance based on date selection in slicer
- 7 years ago
Hi Brysonds ,
I created the sample as your requested. then add the measure:
Variance = var a = CALCULATE(MAX(Table1[Sales]),FILTER(ALL(Table1),[Date (English)]=MAX(Table1[Date (English)]))) var b = CALCULATE(MAX(Table1[Sales]),FILTER(ALL(Table1),[Date (English)]=MIN(Table1[Date (English)]))) Return b-a
Result shown as below:
pbix attached:
Best regards,
Dina Ye
Hi Brysonds ,
I created the sample as your requested. then add the measure:
Variance = var a = CALCULATE(MAX(Table1[Sales]),FILTER(ALL(Table1),[Date (English)]=MAX(Table1[Date (English)]))) var b = CALCULATE(MAX(Table1[Sales]),FILTER(ALL(Table1),[Date (English)]=MIN(Table1[Date (English)]))) Return b-a
Result shown as below:
pbix attached:
Best regards,
Dina Ye
Hi v-diye-msft Dina,
Thanks so much for taking the time to put this together. This gets me really close!
I tried using the formula you provided, and I get the following result. The variance is not calculating correctly
I tried altering the formula to this and it fixed the amounts, but has the wrong sign:
Variance =
Here you can see that the variance for the first line is -27.20, but it should be positive (Jan - Feb asset amount).
Any ideas?
Also, is there a way to hide the "variance" columns that show 0 and only show the variance sub-total?
- v-diye-msft7 years agoCommunity Support
Hi Brysonds ,
Take a try of this:
Variance = var P1 = CALCULATE(MAX(CSE[Asset Amount]),FILTERS(CSE[Fiscal Year / Period])) var P2 = CALCULATE(MIN(CSE[Asset Amount]),FILTERS(CSE[Fiscal Year / Period])) var P3 = CALCULATE(CSE[Fiscal Year / Period]),FILTER(CSE,CSE[Asset Amount]=P1)) var P4 = CALCULATE(CSE[Fiscal Year / Period]),FILTER(CSE,CSE[Asset Amount]=P2)) Return IF(P3<P4,P1-P2,P2-P1)
Regarding to the 0 in the matrix, we can't remove it currently. probably you can adjust the font color or other format to make it unconspicuous.
Best regards,
Dina Ye