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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
weibing86
Regular Visitor

Calculate difference between columns for matrix table with few levels of column header

I have the following sets of data:

 

FYACT/BUDBusiness UnitGL Category Value 
2023ACTU1Sales  1,000.00
2023ACTU1Cost   (300.00)
2023ACTU1Profit     700.00
2023BUDU1Sales     500.00
2023BUDU1Cost   (100.00)
2023BUDU1Profit     400.00
2023ACTU2Sales     700.00
2023ACTU2Cost   (200.00)
2023ACTU2Profit     500.00
2023BUDU2Sales     800.00
2023BUDU2Cost   (500.00)
2023BUDU2Profit     300.00
2023ACTU3Sales     400.00
2023ACTU3Cost   (200.00)
2023ACTU3Profit     200.00
2023BUDU3Sales     600.00
2023BUDU3Cost   (500.00)
2023BUDU3Profit     100.00

 

After converting the data into matrix table, I would like to insert columns showing difference between ACT and BUD for different business units as follows:

 202320232023202320232023202320232023
 ACTACTACTBUDBUDBUDDIFFDIFFDIFF
 U1U2U3U1U2U3U1U2U3
Sales 1,000.00    700.00    400.00    500.00    800.00    600.00    500.00   (100.00)   (200.00)
Cost   (300.00)   (200.00)   (200.00)   (100.00)   (500.00)   (500.00)   (200.00)    300.00    300.00
Profit    700.00    500.00    200.00    400.00    300.00    100.00    300.00    200.00    100.00

 

Can someone enlighten on how to insert the columns showing difference?

1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @weibing86,

 

The look you are trying to achieve is not achievable by simply creating measures to calculate for Actual, Budget and the difference. Here's how that would look using that approach.

danextian_0-1709641812359.png

Notice that the measures are below the business units instead of other way around.

To achieve what you want, you need to create a disconnected table that has a column of the name of the measures and another measure that will return the respective actual measures depending on the value of the said column. That approach would yield this:

danextian_1-1709641929304.png

Take note that the matrix visual does not repeat column headers so you will see just one ACT/BUD/DIFF across all business units.

 

Please see attached pbix for reference.

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

6 REPLIES 6
weibing86
Regular Visitor

Hi guys, thanks for your help.

 

Actually my scenario is even more completed as I have slicer which allows me to choose different paramets, eg FY, BU, entity, so my matrix table is dynamic.

 

Is there a way to directly compute the difference between columns based on the table generated after selecting desired parameters in slicer?

Hi @weibing86 

Have you opened my sample pbix and played with it? Which part doesnt work for you? I would suggest you posted a sample data that covered your use case and further expounded on it instead of just bits and pieces. and





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hi i have finall understood your method.

 

First, you created a new measure DIFF, which is difference between the 2 measures ACT and BUD. Then split this DIFF to different parameters (e.g. FY, business unit etc). This works for me.

 

However, when i used your 2nd method which is the 'switch' measure, only ACT and BUD showed up; the DIFF columns do not show up. I have followed exactly the steps in your file, is there any step which i may have missed?

XX

danextian
Super User
Super User

Hi @weibing86,

 

The look you are trying to achieve is not achievable by simply creating measures to calculate for Actual, Budget and the difference. Here's how that would look using that approach.

danextian_0-1709641812359.png

Notice that the measures are below the business units instead of other way around.

To achieve what you want, you need to create a disconnected table that has a column of the name of the measures and another measure that will return the respective actual measures depending on the value of the said column. That approach would yield this:

danextian_1-1709641929304.png

Take note that the matrix visual does not repeat column headers so you will see just one ACT/BUD/DIFF across all business units.

 

Please see attached pbix for reference.

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
sanalytics
Super User
Super User

Hello @weibing86 

Create a Disconnected table and used that table as column in Matrix section

 

Create DAX to show the difference.

 

Below is the screenshot

sanalytics_0-1709641917841.png

Below is the link of complete solution of pbix file

https://dropmefiles.com/K4aE6

 

Regards

sanalytics

If it is your solution then please like and accept it as solution

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.

Top Solution Authors