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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Philfound1199
Frequent Visitor

Adding a New column to Matrix that find the difference between two columns

Hello, 

 

I have this Matrix and I would like to be able to add a third column to the right that shows the difference between the two year columns. The Matrix is just all these values and then year in the columns. I know this is kinda out of the bounds of what a matrix is meant to do but if anyone has suggestions on how to go about this or a work around please let me know. 

 

matrixquestion.PNG

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Philfound1199 
You may activate the columns total and rename it "Difference". Use the following measure in the matrix visual values.

ResultMeasure =
IF (
    HASONEVALUE ( 'Table'[Fiscal Year] ),
    [Measure],
    CALCULATE ( [Measure], 'Table'[Fiscal Year] = MAX ( 'Table'[Fiscal Year] ) )
        - CALCULATE ( [Measure], 'Table'[Fiscal Year] = MIN ( 'Table'[Fiscal Year] ) )
)

View solution in original post

3 REPLIES 3
Philfound1199
Frequent Visitor

Thanks that worked great! If you have the time can you explain how overriding the column subtotal works. I'm trying to have a better understanding of whats going on here.

@Philfound1199 

The following usually comes as a surprise to all new Power Bi users. 
The Total in power bi does not actually sum the visible values in the matrix. It is evaluated just as any other cell but in different filter context. In you example the total column is evaluated in the context of ALL ( [fiscal year] ). If the measure is of additive nature, total column will show the sum of all years. However, we can change that and produce the difference for example. By checking IF [fiscal year] HASEONVALUE (such as in f2023 and f2024) we can apply the normal measure while otherwise we can apply the difference between the value of the max year and the value of the min year. As simple as that. 

tamerj1
Super User
Super User

Hi @Philfound1199 
You may activate the columns total and rename it "Difference". Use the following measure in the matrix visual values.

ResultMeasure =
IF (
    HASONEVALUE ( 'Table'[Fiscal Year] ),
    [Measure],
    CALCULATE ( [Measure], 'Table'[Fiscal Year] = MAX ( 'Table'[Fiscal Year] ) )
        - CALCULATE ( [Measure], 'Table'[Fiscal Year] = MIN ( 'Table'[Fiscal Year] ) )
)

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.