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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Sk1_2
Frequent Visitor

Calculate difference between multiple columns and then highlighting the difference

Sk1_2_0-1711121533270.png

Hello I am trying to calculate the difference between mutiple columns in PowerBI. And Highlight changes above and below 50 w/ color. I haven't been able to find any examples with multiple columns.  I believe I have to create a measure but I'm not sure what calcualtions to use. Any help would be much appreciated. 

 

4 REPLIES 4
v-yanimei-msft
Community Support
Community Support

Hi all , 

@QuentinBl , thanks for your concern about this case, I have some additions for problem solving.

@Sk1_2 , thank you for giving a specific description of the problem. Based on your description, I will give you the following steps to solve the problem.

1.The test table Table.

vyanimeimsft_0-1711429335288.png

2.New Measures and input the DAX code of calculating difference for individual columns.

 

Difference between Sum of 1 and Sum of 2 = SUM('Table'[Sum of 1])-SUM('Table'[Sum of 2])
Difference between Sum of 1 and Sum of 3 = SUM('Table'[Sum of 1])-SUM('Table'[Sum of 3])
Difference between Sum of 1 and Sum of 4 = SUM('Table'[Sum of 1])-SUM('Table'[Sum of 4])
Difference between Sum of 2 and Sum of 3 = SUM('Table'[Sum of 2])-SUM('Table'[Sum of 3])
Difference between Sum of 2 and Sum of 4 = SUM('Table'[Sum of 2])-SUM('Table'[Sum of 4])

 

3.Add these measures to columns.

vyanimeimsft_1-1711429501057.png

4.Conditional formatting. Refer to Apply conditional table formatting in Power BI - Power BI | Microsoft Learn. All measures follow the steps:

a.Click the drop-down arrow, select Conditional formatting > Background color.

b.Select Rules as Format style.

c.Select Number or Percentage as value type.

d.Select the color you want to display.

You can modify them according to your needs.

vyanimeimsft_2-1711429581368.pngvyanimeimsft_3-1711429590425.png

5.The outcome is in the following picture.

vyanimeimsft_4-1711429620510.png

 

 

Best Regards,

Caroline Mei

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

Thank you! Can this formula work in a Matrix? 

@Sk1_2 , you can realize it in a Matrix. Now, I will show you how to realize it in a Matrix.

1.Modify the test table Table. Add a column ValueType, so that you can use it as the row later.

vyanimeimsft_0-1711505516484.png

2.Add ValueType to Rows, and add Sum of 1, Sum of 2, Sum of 3, Sum of 4, Difference between Sum of 1 and Sum of 2, … to Values.

vyanimeimsft_1-1711505532422.png

3.The outcome is in the following picture.

vyanimeimsft_2-1711505547037.png

Best Regards,

Caroline Mei

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

QuentinBl
Helper I
Helper I

Hello,

if you want the differences between two columns, you can do this : measure = SUM(Sum of 1) - SUM(SUM of 2).. etc
if you want the differences in % to do a highlight when the differences is > than 50%, you should do something like this, and use the pourcentage as a "cell elements" : 

Pourcentage = DIVIDE(SUM('Table (2)'[Value 2]) - SUM('Table (2)'[Value 1]),SUM('Table (2)'[Value 1]) )

If your columns are something like a date, or months, you should think about do a pivot to get thoses columns in rows. And then use DAX date functions to compare thoses dates.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.