cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

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
v-binbinyu-msft
Community Support
Community Support

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
v-binbinyu-msft
Community Support
Community Support

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
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors