Forum Discussion
Table percentage between columns
Hi,
I would like to add per each row the percentage difference from previous year and even possibility to hide and show quarter from this matrix, so that utomatically calculate percentage difference from total between years
So if quarter is seleceted i would like to see for the first row
| Country | 2021 | 2022 | 2023 | ||||
| Budget | Delta | Budget | Delta | Budget | Delta | ||
| Hungary | Q1 | 48526 | 83935 | +72.9% | 69743 | -16.90% |
Thanks in advanced
Hi Gpera ,
Based on the sample and description you provided, Please try code as below to create a measure.
Change Percentage = VAR _pre = CALCULATE(SUM('Table'[Budget]), FILTER(ALLSELECTED('Table'), [Country]=MAX('Table'[Country])&&[Quarter Q]=MAX('Table'[Quarter Q])&&[Year]=MAX('Table'[Year])-1) ) VAR _pre2 = CALCULATE(SUM('Table'[Budget]), FILTER(ALLSELECTED('Table'), [Country]=MAX('Table'[Country])&&[Year]=MAX('Table'[Year])-1) ) VAR _cur = SUM('Table'[Budget]) RETURN IF(ISINSCOPE('Table'[Quarter Q]), DIVIDE(_cur-_pre,_pre), DIVIDE(_cur-_pre2,_pre2) )Result is as below.
Best Regards,
Yulia Yan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
2 Replies
- FowmySuper User
- v-weiyan1-msftCommunity Support
Hi Gpera ,
Based on the sample and description you provided, Please try code as below to create a measure.
Change Percentage = VAR _pre = CALCULATE(SUM('Table'[Budget]), FILTER(ALLSELECTED('Table'), [Country]=MAX('Table'[Country])&&[Quarter Q]=MAX('Table'[Quarter Q])&&[Year]=MAX('Table'[Year])-1) ) VAR _pre2 = CALCULATE(SUM('Table'[Budget]), FILTER(ALLSELECTED('Table'), [Country]=MAX('Table'[Country])&&[Year]=MAX('Table'[Year])-1) ) VAR _cur = SUM('Table'[Budget]) RETURN IF(ISINSCOPE('Table'[Quarter Q]), DIVIDE(_cur-_pre,_pre), DIVIDE(_cur-_pre2,_pre2) )Result is as below.
Best Regards,
Yulia Yan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.