Forum

Diff between two co...
 
Notifications
Clear all

Diff between two columns

5 Posts
2 Users
0 Reactions
413 Views
(@raman)
Posts: 33
Trusted Member
Topic starter
 

Hi

I have created in a pivot table with monthly columns of amounts.

I select any two monthly columns by filter and I want to find the difference between the selected monthly columns

Rows       Apr 21    Jun 21

Sales        XXX        XXX

I want to find the diff between the above two columns.  The month can be any selected from column filter.

The DAX should give the diff whatever the column choses.  Thanks.

Rgds

Thulasi

 
Posted : 11/10/2021 7:18 am
(@mynda)
Posts: 4761
Member Admin
 

Hi Thulasi,

You can use the PREVIOUSMONTH function to calculate this. e.g.:

=SUM(Table1[Value])-CALCULATE(SUM(Table1[Value]), PREVIOUSMONTH(Table1[Date]))

 

If you're stuck, it's best to provide a small sample file so we can help you better.

Mynda

 
Posted : 11/10/2021 7:36 pm
(@raman)
Posts: 33
Trusted Member
Topic starter
 

Hi Mynda

Thank you for quick reply as always.

Your solution is perfect in giving the diff between two consecutive months.

Row        May 21       June 21       Diff  (consecutive months)

Sales         100            110            10

But it does not work for below case, if the two months are random period.

Row        Dec 20       June 21       Diff    (random months)

Sales         100            110            10

Also I may select some other fields like Categories instead of months.

Row         Cat A        Cat C           Diff (random fields)

Sales         100            110            10

Is it possible to create DAX for above requirement?  Eagerly waiting.  Thanks.

Rgds

Thulasi

 
Posted : 12/10/2021 8:21 am
(@mynda)
Posts: 4761
Member Admin
 

Hi Thulasi,

Perhaps this is what you're after.

Mynda

 
Posted : 12/10/2021 7:56 pm
(@raman)
Posts: 33
Trusted Member
Topic starter
 

Wow.....I think that's the issue I wanted to solve, Mynda.

Let me try to apply that DAX and comment back.

Thanks a ton.

 
Posted : 14/10/2021 2:20 am
Share: