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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
mangchaaBI
Helper II
Helper II

Matrix Visual, Find Difference Between 2 Columns, Dynamic Data Filtered by Last 2 Calendar Months

Hi All,

 

It's me again, just need some help in getting the difference between 2 month columns in my report using Matrix visualization

 

The months are automatically filtered using Last 2 Calendar Months

 

mangchaaBI_0-1665010340066.png

 

Thanks as always!

 

1 ACCEPTED SOLUTION
hnguy71
Super User
Super User

@mangchaaBI ,

 

In this case, you would need a minimum of three measures. I'm assuming you already have two measures created. I am hoping my assumption is correct. If not you'll need to create those measures.

 

1 for the sum of the last 2 months

1 for the sum of the last 1 month

 

You would then take the sum of both and subtract the other. In your case the formula would be..

 

Delta := [Last1Month] - [Last2Month]

 



Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

View solution in original post

4 REPLIES 4
v-yadongf-msft
Community Support
Community Support

Hi @mangchaaBI ,

 

I think you'd better use a table visual.

This is my test table:

vyadongfmsft_0-1665022206689.png

 

Please try following DAX to create three new columns:

Last 2 month_August = CALCULATE(SUM('Table'[Value]),FILTER('Table',MONTH('Table'[Date])=8 && 'Table'[ItemName]=EARLIER('Table'[ItemName])))

Last 1 month_September = CALCULATE(SUM('Table'[Value]),FILTER('Table',MONTH('Table'[Date])=9 && 'Table'[ItemName]=EARLIER('Table'[ItemName])))

Difference = [Last 1 month_September] - [Last 2 month_August]

vyadongfmsft_1-1665022351450.png

 

Create a table visual:

vyadongfmsft_2-1665022386026.png

Best regards,

Yadong Fang

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

And what if I need the years to be dynamically selected by the user instead of manually input?

hnguy71
Super User
Super User

@mangchaaBI ,

 

In this case, you would need a minimum of three measures. I'm assuming you already have two measures created. I am hoping my assumption is correct. If not you'll need to create those measures.

 

1 for the sum of the last 2 months

1 for the sum of the last 1 month

 

You would then take the sum of both and subtract the other. In your case the formula would be..

 

Delta := [Last1Month] - [Last2Month]

 



Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

Hi @hnguy71  I don't have the measures created yet, but I think I'm getting your instructions, can take it from here, thanks! 

Helpful resources

Announcements
December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.