Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Swamy3105
Helper IV
Helper IV

How to subtract the values between two months in the same column using calculated column

Hi Experts,

 

please help me to acheive the below:

 

I tried hard but nothing is working.

 

Swamy3105_0-1715886749206.png

I want to subtract the value  = Dec-Jan = -16.28

 

Please help me on this.

 

Regards.,

Swamy

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Swamy3105 ,

Below is my table:

vxiandatmsft_0-1717479328954.png

You can create a index column:

vxiandatmsft_1-1717479349689.png

The following DAX might work for you:

output = 
var _a =  CALCULATE(max('table'[value]),filter('table','table'[index]=earlier('table'[index])+1))
RETURN
  'Table'[Value] - _a

The final output is shown in the following figure:

vxiandatmsft_2-1717479400523.png

Best Regards,

Xianda Tang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Ray_Minds
Responsive Resident
Responsive Resident

You could be use measure instead of calculated column. I believe measure is best option to summarize the expression and also good to performance. you will use below expression as seen in the snapshot.
image (3).png

Anonymous
Not applicable

Hi @Swamy3105 ,

Thank you for @Syndicate_Admin answer , and I have other suggestions:

Below is my table:

vxiandatmsft_0-1715914184602.png

The following DAX might work for you:

Column = 
 VAR _month = MIN('Table'[Year])
 VAR _new_month = MONTH(EDATE(_month,1))
 VAR _a = CALCULATE(MAX('Table'[FIFO]),FILTER('Table',MONTH('Table'[Year]) = _new_month))
 VAR _b = CALCULATE(MAX('Table'[FIFO]),FILTER('Table',MONTH('Table'[Year]) = MONTH(_month)))
 RETURN
 _b - _a

The final output is shown in the following figure:

vxiandatmsft_1-1715914216850.png

Best Regards,

Xianda Tang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @Syndicate_Admin 

 

thanks for your dax, but I need to subtract the value from current month to previous month as below:

 

Swamy3105_0-1715923405115.png

 

Regards.,

Swamy

Anonymous
Not applicable

Hi @Swamy3105 ,

Below is my table:

vxiandatmsft_0-1717479328954.png

You can create a index column:

vxiandatmsft_1-1717479349689.png

The following DAX might work for you:

output = 
var _a =  CALCULATE(max('table'[value]),filter('table','table'[index]=earlier('table'[index])+1))
RETURN
  'Table'[Value] - _a

The final output is shown in the following figure:

vxiandatmsft_2-1717479400523.png

Best Regards,

Xianda Tang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Syndicate_Admin
Administrator
Administrator

Nice

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.