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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Jay92SG
New Member

Calculate difference between current month and previous month for cumulative data

Hi, i have a report that i can extract on a monthly basis. 

 

For example,

 

Date                Asset ID      Transaction
1 Dec 2022          123               0
1 Jan 2023          123             1000
1 Feb 2023         123             1000
1 Mar 2023         123             1000

I need to get the monthly additions for Mar 2023, i will need to take the transaction for Mar23 (1000) and deduct Feb23 (1000) to get 0 additions. It would mean that for Jan23, it is $1000 addition using Jan23 (1000) -  Dec22(0).

the report is a long list with many different asset ID. can anyone help me? i have tried the below but doesnt work. I am thinking i will need to summarize by asset ID first, and for each row, compute the difference by looking up to the previous month transaction. 
AdditionCM = (CALCULATE( sum(ZFA0006[Transaction]) , LASTDATE(ZFA0006[Date])) )- (CALCULATE( sum(ZFA0006[Transaction]) , PREVIOUSMONTH(ZFA0006[Date])) )


1 ACCEPTED SOLUTION
v-tangjie-msft
Community Support
Community Support

Hi @Jay92SG ,

 

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

(1) My test data is the same as yours.

(2) We can create a measure. 

addition using = 
var _a=CALCULATE(SUM('Table'[Transaction]),FILTER(ALL('Table'),'Table'[Asset ID]=MAX('Table'[Asset ID]) && YEAR('Table'[Date])=YEAR(EOMONTH(MAX('Table'[Date]),-1)) && MONTH('Table'[Date])=MONTH(EOMONTH(MAX('Table'[Date]),-1))))
return MAX('Table'[Transaction])-_a

(3) Then the result is as follows.

vtangjiemsft_0-1692240463211.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

1 REPLY 1
v-tangjie-msft
Community Support
Community Support

Hi @Jay92SG ,

 

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

(1) My test data is the same as yours.

(2) We can create a measure. 

addition using = 
var _a=CALCULATE(SUM('Table'[Transaction]),FILTER(ALL('Table'),'Table'[Asset ID]=MAX('Table'[Asset ID]) && YEAR('Table'[Date])=YEAR(EOMONTH(MAX('Table'[Date]),-1)) && MONTH('Table'[Date])=MONTH(EOMONTH(MAX('Table'[Date]),-1))))
return MAX('Table'[Transaction])-_a

(3) Then the result is as follows.

vtangjiemsft_0-1692240463211.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. 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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