Forum Discussion
subtraction same colum
- 6 years ago
Hi Jcastill ,
You need a calendar table and create relationships with the fact table.
Then create measure like this:
Subtract Previous Year = var VarThis = SUM('Table'[value]) var LastYear =CALCULATE(SUM('Table'[value]),dateadd('Table 2'[date],-1,YEAR)) return IF( VarThis - LastYear = 0, VarThis, VarThis - LastYear)Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hey Jcastill
Thanks for writing a post. I think I've got a solution to your issue, but without the underlying data I can't say for certain if this will work for you
First I've started out with these test data based on your snippet
Next I created a measure to take the max value and subtract if the previous years value. If the value is 0, we are going to show it as blank.
Subtract Previous Year =
var VarThis = CALCULATE(MAX('Test Data'[Value]))
var LastYear = CALCULATE(MAX('Test Data'[Value]), 'Test Data'[Year] - 1)
return
IF(
VarThis - LastYear = 0, BLANK(), VarThis - LastYear)
Once I throw that value into the matrix, I added some condition formatted (I didn't choose visually appealing colors and I apologize for that blunder)
In this case we have a column for the actual value and to the right a column indicating the change for that month from the previous year.
Let me know if solution works for you or if we want to try and think of something else!
- Jcastill6 years agoRegular Visitor
Hello,
thank you for your help. but I have the same problem.
I create a measure :
Subtract Previous Year =var VarThis = CALCULATE(MAX(VW_ARAGING[Amount OVerdue]))var LastYear = CALCULATE(MAX(VW_ARAGING[Amount OVerdue]), VW_ARAGING[Eff date].[Year] - 1)returnIF(VarThis - LastYear = 0, BLANK(), VarThis - LastYear)but the result is blank😞