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
vivek09
Regular Visitor

How to find difference of two identical tables in Power BI Visualisation Matrix

Hi Guys, I am new to power BI. I got visualization of two tables using 'Matrix' option in build visual.

1. Actual Sales

2. Target Sales

 

Actual Sales

vivek09_0-1687262011281.png

 

Target Sales

vivek09_2-1687262279660.png

 

 

Now, I'm struggling to create another 'Matrix' visual table that can give me difference of two tables.

 

3. Difference in table values.

 

vivek09_3-1687262299728.png

 

I can't find any visuals, that could help be do this subtraction between the visuals tables ? 

vivek09_4-1687262348592.png

Thanks in advance.

 

Cheers!

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @vivek09 ,

Please try below steps:

1. create measure with below dax formula

 

Branch1 =
VAR cur_cty =
    SELECTEDVALUE ( 'Target Sales'[Category] )
VAR _a =
    CALCULATE (
        MAX ( 'Actual Sales'[Branch 1] ),
        'Actual Sales'[Category] = cur_cty
    )
VAR _b =
    CALCULATE (
        MAX ( 'Target Sales'[Branch 1] ),
        'Target Sales'[Category] = cur_cty
    )
RETURN
    _a - _b
Branch2 =
VAR cur_cty =
    SELECTEDVALUE ( 'Target Sales'[Category] )
VAR _a =
    CALCULATE (
        MAX ( 'Actual Sales'[Branch 2] ),
        'Actual Sales'[Category] = cur_cty
    )
VAR _b =
    CALCULATE (
        MAX ( 'Target Sales'[Branch 2] ),
        'Target Sales'[Category] = cur_cty
    )
RETURN
    _a - _b
Branch3 =
VAR cur_cty =
    SELECTEDVALUE ( 'Target Sales'[Category] )
VAR _a =
    CALCULATE (
        MAX ( 'Actual Sales'[Branch 3] ),
        'Actual Sales'[Category] = cur_cty
    )
VAR _b =
    CALCULATE (
        MAX ( 'Target Sales'[Branch 3] ),
        'Target Sales'[Category] = cur_cty
    )
RETURN
    _a - _b
A =
VAR _a = [Branch1] RETURN IF ( _a > 0, "black", "red" )
B =
VAR _a = [Branch2] RETURN IF ( _a > 0, "black", "red" )
C =
VAR _a = [Branch3] RETURN IF ( _a > 0, "black", "red" )

 

2. add a matrix visual with table filed and measure, apply A,B,C measure to conditional format for font color

vbinbinyumsft_0-1687506074612.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
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

4 REPLIES 4
Anonymous
Not applicable

Hi @vivek09 ,

Please try below steps:

1. create measure with below dax formula

 

Branch1 =
VAR cur_cty =
    SELECTEDVALUE ( 'Target Sales'[Category] )
VAR _a =
    CALCULATE (
        MAX ( 'Actual Sales'[Branch 1] ),
        'Actual Sales'[Category] = cur_cty
    )
VAR _b =
    CALCULATE (
        MAX ( 'Target Sales'[Branch 1] ),
        'Target Sales'[Category] = cur_cty
    )
RETURN
    _a - _b
Branch2 =
VAR cur_cty =
    SELECTEDVALUE ( 'Target Sales'[Category] )
VAR _a =
    CALCULATE (
        MAX ( 'Actual Sales'[Branch 2] ),
        'Actual Sales'[Category] = cur_cty
    )
VAR _b =
    CALCULATE (
        MAX ( 'Target Sales'[Branch 2] ),
        'Target Sales'[Category] = cur_cty
    )
RETURN
    _a - _b
Branch3 =
VAR cur_cty =
    SELECTEDVALUE ( 'Target Sales'[Category] )
VAR _a =
    CALCULATE (
        MAX ( 'Actual Sales'[Branch 3] ),
        'Actual Sales'[Category] = cur_cty
    )
VAR _b =
    CALCULATE (
        MAX ( 'Target Sales'[Branch 3] ),
        'Target Sales'[Category] = cur_cty
    )
RETURN
    _a - _b
A =
VAR _a = [Branch1] RETURN IF ( _a > 0, "black", "red" )
B =
VAR _a = [Branch2] RETURN IF ( _a > 0, "black", "red" )
C =
VAR _a = [Branch3] RETURN IF ( _a > 0, "black", "red" )

 

2. add a matrix visual with table filed and measure, apply A,B,C measure to conditional format for font color

vbinbinyumsft_0-1687506074612.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks very much for this. If I have like 15 to 20 branches, do I need to create individual measures to capture these ? or is there a simpler way for aggregation? 

 

Thank you

some_bih
Super User
Super User

Hi @vivek09 organize your data so in new column you have Branch 1/2/3 so you can slices / show it in column with matrix visual. Hope this help.





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

Proud to be a Super User!






some_bih
Super User
Super User

Hi @vivek09 organize your data so in new column you have Branch 1/2/3 so you can slices / show it in column with matrix visual. Hope this help.





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

Proud to be a Super User!






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.