Forum Discussion
Difference between 2 columns in a Matrix Table
Hi.
I am trying to calculate the difference between 2 columns i Desktop.
The value is a measure and the columns are one field, pls. see below.
I have tried to create a measure but with no luck.
For January the new column should be -15
February -12
......
July +38
Any suggestions?
Thanks a lot.
10 Replies
- AnonymousNot applicable
- v-frfei-msftCommunity Support
- HEWHelper III
Hi Frank.
Is it really so complicated? I'll try and adapt the formula to my data and hope it works :smileyhappy: Thanks.
Br. Helen
- v-frfei-msftCommunity Support
Hi HEW,
I made one sample for your reference.
1. Enter the data as your description and create a calculated table.
Table = SUMMARIZE(Table1,Table1[Month],Table1[mo],Table1[Year],"sum",SUM(Table1[Amount]))
2. Create a calculated column in Table.
diff = var prevalue = CALCULATE(FIRSTNONBLANK('Table'[sum],1), FILTER('Table',('Table'[Year]= (EARLIER('Table'[Year])-1)) && 'Table'[mo]= EARLIER('Table'[mo]))) return IF(ISBLANK(prevalue), BLANK(),'Table'[sum]-prevalue)3. Then we can get the result as we excepted.
For more details, please check the pbix as attached.
Regards,
Frank
- Ashish_MathurSuper User
Hi,
If there is also a Date column available in your dataset, then you should create a relatiosnhip between this Date column and the Date column of your Calendar Table. In the Calendar Table, write the following calculated column formulas to extract the Year and Month
Year=year(Calendar[Date])
Month=FORMAT(Calendar[Date],"mmmm")
In your visual, drag Year and Month from the Calendar Table. Then write this measure
[Proposals Count]-CALCULATE([Proposals Count],SAMEPERIODLASTYEAR(Calendar[Date]))
Hope this helps.
- HEWHelper III
Hi Ashish.
It works perfectly! Would it be possible to leave out the difference for 2017 as it is the same value as the count?
Br. Hele
- Ashish_MathurSuper User
Hi,
I don't think that is possible.