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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
wy_khoo
Frequent Visitor

Substract first value in the table column

Hi, 

 

I have a matrix table showing data for each month.

 

Can you please advise what is the formula to calculate difference between last month vs first month.

 

For example: 14-49 = -35

wy_khoo_0-1705909460845.png

 

Thank you in advance!

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @wy_khoo ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data. 

vtangjiemsft_0-1706151736470.png

(2) We can create a measure. 

Measure = 
var _first_date=CALCULATE(MIN('Table'[date]),ALLSELECTED('Table'))
var _first_value=CALCULATE(SUM('Table'[value]),FILTER(ALLSELECTED('Table'),MONTH('Table'[date])=MONTH(_first_date) && YEAR('Table'[date])=YEAR(_first_date)))
var _value=CALCULATE(SUM('Table'[value]),FILTER(ALLSELECTED('Table'),YEAR('Table'[date])=YEAR(MAX('Table'[date])) && MONTH('Table'[date])=MONTH(MAX('Table'[date]))))
RETURN _value-_first_value

(3) Then the result is as follows.

vtangjiemsft_1-1706151802892.png

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko 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

3 REPLIES 3
Anonymous
Not applicable

Hi @wy_khoo ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data. 

vtangjiemsft_0-1706151736470.png

(2) We can create a measure. 

Measure = 
var _first_date=CALCULATE(MIN('Table'[date]),ALLSELECTED('Table'))
var _first_value=CALCULATE(SUM('Table'[value]),FILTER(ALLSELECTED('Table'),MONTH('Table'[date])=MONTH(_first_date) && YEAR('Table'[date])=YEAR(_first_date)))
var _value=CALCULATE(SUM('Table'[value]),FILTER(ALLSELECTED('Table'),YEAR('Table'[date])=YEAR(MAX('Table'[date])) && MONTH('Table'[date])=MONTH(MAX('Table'[date]))))
RETURN _value-_first_value

(3) Then the result is as follows.

vtangjiemsft_1-1706151802892.png

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

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

Hi @Anonymous , thank you for your solution. It works!

Ritaf1983
Super User
Super User

Hi @wy_khoo 

Please refer to the linked tutorial:

https://www.youtube.com/watch?v=cAxoxvnN_vQ

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.