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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.

Top Solution Authors