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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
ES_TH
Frequent Visitor

PowerBi Matrix Table - Compare 2 different variables of same object

Hi,
 
I am using PowerBi and am trying to solve a problem of comparing the outcomes of 2 columns that are showing the same object but with 2 possible outcomes. Basically it's almost a what if scenario with column 3 being the what if... but not quite!  Anyway, I will then do some analyse on percentage changes, differences and a bunch of other stuff with extended dataset. Simplifying the main problem see below:
 
DATA TABLE EXAMPLE.
ID Apples Apples -1
C110
C221
C343
C454
C565
C643
C732
C821
C921
C1010

 

Problem is when I put table into a matrix (pivot table) my total is always 10 which is fine but my count of apples is always the same in relation to how many people have 1 or 2 apples if i use "Apples" column and put values as Apples and Apples-1. Eg output would look like:

 

Apples Apples Apples -1
122
233
311
422
511
611

 

Desired Pivot/Matrix result (2nd and 3rd columns are value counts)

Apples Apples Apples -1
002
123
231
312
421
511
610

I have tried all sorts but can't figure out how to get the desired count in column 2 and 3 of pivot. used Apples-1 to get 0 to 6 in rows but result is same in that count is same for both 2nd and 3rd column! What do I need to do to get the 0 in first (Apples) column if using "Apples" as Rows. tried to duplicate Table and connect with Dim table that has 1 to 6 but that got confusing quick and didn't work! Any ideas, what am I doing wrong!!! I get that it's something to do with IDs but how do I get it to adjust?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @ES_TH 

 

For your question, here is the method I provided:

 

First, go to the power query and Unpivot Columns for Apples and Apples-1.

 

vnuocmsft_0-1714014917831.png

 

vnuocmsft_1-1714014947247.png

 

Create a measure.

 

Measure = 
    CALCULATE(
        COUNT('Table'[Attribute]), 
        FILTER(
            'Table', 
            'Table'[Attribute] = MAX('Table'[Attribute]) 
            && 
            'Table'[Value] = MAX('Table'[Value])
        )
    )

 

Here is the result.

 

vnuocmsft_2-1714015079272.png

 

Regards,

Nono Chen

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

2 REPLIES 2
Anonymous
Not applicable

Hi @ES_TH 

 

For your question, here is the method I provided:

 

First, go to the power query and Unpivot Columns for Apples and Apples-1.

 

vnuocmsft_0-1714014917831.png

 

vnuocmsft_1-1714014947247.png

 

Create a measure.

 

Measure = 
    CALCULATE(
        COUNT('Table'[Attribute]), 
        FILTER(
            'Table', 
            'Table'[Attribute] = MAX('Table'[Attribute]) 
            && 
            'Table'[Value] = MAX('Table'[Value])
        )
    )

 

Here is the result.

 

vnuocmsft_2-1714015079272.png

 

Regards,

Nono Chen

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

 

Hi,

 

This is an excellent solution.  Thank you.  As I am new to this I just wanted to understand some the logic in this.  I get the pivoting which is fine but it is the measure that doesn't qute make sense to me and also I am having problems calculating percenatge change as I thought you could use the  "New Calculation" on visula but it doesn't seem to recognise the columns.  So getting to the point and being more explicit see the logic I was trying to ascertain from visuals:

 

ES_TH_0-1714395433121.png

 

1. What is the point of the measure if I get the same output from just using the attributes in the values and doing a count

ES_TH_1-1714397331335.png

 

ES_TH_2-1714397418623.png

2.  What is the Filter with max for attribute and value adding.

 

3. How do I get to do calculations on these columns?  I thought the "new calculation" on visual would of helped but it doesn't seem to recognise the measure column so I can tell it to calculate percentage change for Apples and Apples-1 (I'm sure it is really simple and my syntax understanding is just missing as newbie to all of this!!!).  Should I or do I even need to do it on the visual?  How would I write a measure to show me this (research says that you can't format visual calculations!).

 

Sorry lots of questions but hope that makes sense.  Will upload PBI file if i can figure out how!  😁

 

 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.