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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
bestevezdyb
Frequent Visitor

Row Measure Difference

Hello,

I would like to know if it is possible to do in the same matrix what I show in the image. It is about calculating the differences between two years for different metrics, and always putting the difference between the years.

 

 SalesUnit
2019205
2020307
Difference102

 

The only solution I found was this one, but, maybe there is a better one.

 

 

salesDifference = 
VAR _year =
    SWITCH (
        TRUE (),
        SELECTEDVALUE ( dim_date[year] ) <> 0, "year",
        BLANK ()
    )
RETURN
IF ( _year = "", [salesDiff], [sales] )
----
WHERE [salesDiff] IS

salesDiff = 

VAR _minsales = 

    CALCULATE( SUM ( fac_sales[sales] ), Filter(dim_date, dim_date[year] = Min( dim_date[year] ) ) )


VAR _maxsales = IF (

    CALCULATE( SUM ( fac_sales[sales] ), Filter(dim_date, dim_date[year] = Max( dim_date[year] ) ) )

RETURN

_maxsales - _minsales

 

 

Thanks

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@bestevezdyb , On of this way is use isinscope or isfiltered and move this diff to grand total

 

new sales = if(isinscope(Date[Year]), [sale], [diff])

 

or something like this

https://community.powerbi.com/t5/Desktop/Grand-Total-in-Bar-Chart/m-p/612631

 

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

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@bestevezdyb , On of this way is use isinscope or isfiltered and move this diff to grand total

 

new sales = if(isinscope(Date[Year]), [sale], [diff])

 

or something like this

https://community.powerbi.com/t5/Desktop/Grand-Total-in-Bar-Chart/m-p/612631

 

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

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

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.