Forum Discussion

Log2Ins's avatar
Log2Ins
New Member
4 years ago
Solved

Conditional expressions using DAX

Hi all,

 

I have a table of the following type:

 

MonthYearQty 1Qty 2
12022500000100000
22022400000150000

 

I want a new column "Delta Qty 2" which is the difference between Qty 2 of the current month and Qty 2 of the previous month, same year. In the above example it shoul be: 150000 - 100000 = 50000

 

How can I do it with DAX?

 

Thanks.

  • Log2Ins , A new column

    Delta Qty 2 =

    var _sum = sumx(filter(Table, [Year] =earlier([Year])  && [Month] =earlier([Month])  -1) , [Qty 2])

    return

    [Qty 2] - _sum

2 Replies

  • Log2Ins , A new column

    Delta Qty 2 =

    var _sum = sumx(filter(Table, [Year] =earlier([Year])  && [Month] =earlier([Month])  -1) , [Qty 2])

    return

    [Qty 2] - _sum