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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
milkywaypowerbi
Helper II
Helper II

Difference between Multiple Columns in Matrix Presented as Rows

Hi,

 

I have the following matrix in powerbi with year as columns and values as rows.

 

Profit is a measure = Revenue - Cost

 

How do I calculate the profit difference between years and present them as row highlighted in yellow below. Thanks!

 

 

milkywaypowerbi_0-1630909727155.png

 

2 ACCEPTED SOLUTIONS

Hi @milkywaypowerbi ,

 

Try this:

Profit Diff =
VAR CurrentYear_ =
    MAX ( Sheet1[Year] )
VAR PreviousYear_ =
    MAXX ( FILTER ( ALL ( Sheet1[Year] ), Sheet1[Year] < CurrentYear_ ), [Year] )
VAR CurrentProfit_ = [Profit]
VAR PreviousProfit_ =
    CALCULATE ( [Profit], FILTER ( ALL ( Sheet1 ), Sheet1[Year] = PreviousYear_ ) )
VAR MinYear_ =
    CALCULATE ( MIN ( Sheet1[Year] ), ALL ( Sheet1 ) )
RETURN
    IF ( CurrentYear_ <> MinYear_, CurrentProfit_ - PreviousProfit_ )

Icey_0-1631092616359.png

 

 

Best Regards,

Icey

 

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

Hi @milkywaypowerbi ,

 

Just create another measure like so:

Profit Diff 2 = SUMX(Sheet1,[Profit Diff])

Icey_0-1631500652549.png

 

 

Best Regards,

Icey

 

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

8 REPLIES 8
amitchandak
Super User
Super User

@milkywaypowerbi , using seperate date/year table. Use year from that table in visual

 

This Year = CALCULATE([Profit]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])))
Last Year = CALCULATE([Profit],filter(ALL('Date'),'Date'[Year]=max('Date'[Year])-1))


diff = [This Year]-[Last Year ]
diff % = divide([This Year]-[Last Year ],[Last Year ])

 

 

Year on column. Show on Row - True ( to show meausre on row)

 

Power BI — Year on Year with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a
https://www.youtube.com/watch?v=km41KfM_0uA

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi,

 

Sorry I am a bit confuse by using a separate table. I created another table for year

 

Here is the link to the powerbi file

:https://drive.google.com/drive/folders/1_iiFNWrVGAyAhHY5hWnSbETcNGygRMYJ?usp=sharing

 

Can you please help me on the file.

 

Thank you so much!

Hi @milkywaypowerbi ,

 

Try this:

Profit Diff =
VAR CurrentYear_ =
    MAX ( Sheet1[Year] )
VAR PreviousYear_ =
    MAXX ( FILTER ( ALL ( Sheet1[Year] ), Sheet1[Year] < CurrentYear_ ), [Year] )
VAR CurrentProfit_ = [Profit]
VAR PreviousProfit_ =
    CALCULATE ( [Profit], FILTER ( ALL ( Sheet1 ), Sheet1[Year] = PreviousYear_ ) )
VAR MinYear_ =
    CALCULATE ( MIN ( Sheet1[Year] ), ALL ( Sheet1 ) )
RETURN
    IF ( CurrentYear_ <> MinYear_, CurrentProfit_ - PreviousProfit_ )

Icey_0-1631092616359.png

 

 

Best Regards,

Icey

 

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

Hi,

 

Thank you so much!

 

However, the total column is not displaying right total difference. I would like a sum of the difference. Can you assist with that?

Hi @milkywaypowerbi ,

 

Just create another measure like so:

Profit Diff 2 = SUMX(Sheet1,[Profit Diff])

Icey_0-1631500652549.png

 

 

Best Regards,

Icey

 

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

Thank you so much!

 

@milkywaypowerbi , whenever we create time intelligence we prefer a separate table like a date table joined with date of the table if you have data only at year level a year table joined on year.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak 

 

I have created another table for the year but the codes are different from my naming so I am getting errors since I am unsure is it referring to the year in revenue sheet or date

Can you please assist with my table names? Thanks!

 

milkywaypowerbi_1-1630913928634.png

 

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.