Forum Discussion
Variance calculation in Table or Matrix
- 3 years ago
Hi AnthNC ,
Based on your description, I have created a simple example:
Please try:
Measure = var _a = CALCULATE(SUM('Table'[Value]),FILTER('Table',[Year]=MIN('Table'[Year]))) var _b = CALCULATE(SUM('Table'[Value]),FILTER('Table',[Year]=MAX('Table'[Year]))) return IF(ISINSCOPE('Table'[Year]),SUM('Table'[Value]),FORMAT(DIVIDE(_b-_a,_a),"Percent"))Change the name of column subtotal:
Final output:
Best Regards,
Jianbo Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi AnthNC ,
Based on your description, I have created a simple example:
Please try:
Measure =
var _a = CALCULATE(SUM('Table'[Value]),FILTER('Table',[Year]=MIN('Table'[Year])))
var _b = CALCULATE(SUM('Table'[Value]),FILTER('Table',[Year]=MAX('Table'[Year])))
return
IF(ISINSCOPE('Table'[Year]),SUM('Table'[Value]),FORMAT(DIVIDE(_b-_a,_a),"Percent"))
Change the name of column subtotal:
Final output:
Best Regards,
Jianbo Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
This is a very clear example thanks for that.
Question, I'm computing a numeric rather than percentage variance. In my (very large) dataset there may be instances where the "subcategory" isn't present in a "year". How can I incorporate COALESCE into the above in order to compute a variance where for a given "subcategory", one "year" is BLANK?
I've tried inserting in both the variables and in the IF(INSCOPE line without any success.
| subcategory | 2016 | 2018 | Variance |
| a | 90 | 90 | |
| b | 20 | 80 | 60 |
| c | 30 | 70 | 40 |
I would've thought this usage of COALESCE would accomplish my objective but I'm stuck: