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

Comparison between X & Y using many criteria

Hi everyone,

I'm beginning with PowerBI and I'm currently stuck , I know how to get what I want to see in Excel, but not in PowerBI so I'm requesting some help 

Hope example is clear enough. Thank you in advance

 

table 1  
ModelTypevalue
A15000
A22020
A3589
B4532
B5577
B64890
B715423

 

table 2  
competitorTypeavailabilty
X1yes
X2yes
X3no
Y1yes
Y2no
Y3no
X4no
X5yes
X6no
X7yes
Y4yes
Y5yes
Y6yes
Y7yes

 

what I'm looking for is :

what Y is missing vs X only when X is available

So 100% is what is available from X only ,then I want to see what we miss with Y vs X

1 ACCEPTED SOLUTION
v-janeyg-msft
Community Support
Community Support

Hi, @cocolinho 

 

It’s my pleasure to answer for you.

I’m a little confused about what you want to calculate, but I tried to understand and calculated the percentage of the total when X=YES and Y=NO under the same type.

Like this:

 

Measure =
VAR tab =
    SUMMARIZE (
        ALL ( TableXY ),
        TableXY[type],
        "y=no",
            VAR x =
                COUNTROWS (
                    FILTER (
                        ALL ( TableXY ),
                        TableXY[type] = EARLIER ( TableXY[type] )
                            && TableXY[availbility] = "YES"
                            && TableXY[competitor] = "X"
                    )
                )
            VAR y =
                COUNTROWS (
                    FILTER (
                        ALL ( TableXY ),
                        TableXY[type] = EARLIER ( TableXY[type] )
                            && TableXY[availbility] = "NO"
                            && TableXY[competitor] = "Y"
                    )
                )
            RETURN
                IF ( x > 0 && y > 0, 1, 0 ),
        "x=yes",
            VAR x =
                COUNTROWS (
                    FILTER (
                        ALL ( TableXY ),
                        TableXY[type] = EARLIER ( TableXY[type] )
                            && TableXY[availbility] = "YES"
                            && TableXY[competitor] = "X"
                    )
                )
            RETURN
                IF ( x > 0, 1, 0 )
    )
VAR yno =
    COUNTROWS ( FILTER ( tab, [y=no] = 1 ) )
VAR xyes =
    COUNTROWS ( FILTER ( tab, [x=yes] = 1 ) )
RETURN
    DIVIDE ( yno, xyes )

 

v-janeyg-msft_0-1602555838914.png

If it doesn’t solve your problems, please feel free to ask me.

 

Best Regards

Janey Guo

 

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

3 REPLIES 3
v-janeyg-msft
Community Support
Community Support

Hi, @cocolinho 

 

It’s my pleasure to answer for you.

I’m a little confused about what you want to calculate, but I tried to understand and calculated the percentage of the total when X=YES and Y=NO under the same type.

Like this:

 

Measure =
VAR tab =
    SUMMARIZE (
        ALL ( TableXY ),
        TableXY[type],
        "y=no",
            VAR x =
                COUNTROWS (
                    FILTER (
                        ALL ( TableXY ),
                        TableXY[type] = EARLIER ( TableXY[type] )
                            && TableXY[availbility] = "YES"
                            && TableXY[competitor] = "X"
                    )
                )
            VAR y =
                COUNTROWS (
                    FILTER (
                        ALL ( TableXY ),
                        TableXY[type] = EARLIER ( TableXY[type] )
                            && TableXY[availbility] = "NO"
                            && TableXY[competitor] = "Y"
                    )
                )
            RETURN
                IF ( x > 0 && y > 0, 1, 0 ),
        "x=yes",
            VAR x =
                COUNTROWS (
                    FILTER (
                        ALL ( TableXY ),
                        TableXY[type] = EARLIER ( TableXY[type] )
                            && TableXY[availbility] = "YES"
                            && TableXY[competitor] = "X"
                    )
                )
            RETURN
                IF ( x > 0, 1, 0 )
    )
VAR yno =
    COUNTROWS ( FILTER ( tab, [y=no] = 1 ) )
VAR xyes =
    COUNTROWS ( FILTER ( tab, [x=yes] = 1 ) )
RETURN
    DIVIDE ( yno, xyes )

 

v-janeyg-msft_0-1602555838914.png

If it doesn’t solve your problems, please feel free to ask me.

 

Best Regards

Janey Guo

 

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

Thanks already @v-janeyg-msft & @amitchandak for your replies. I didn't have time to go through it yet but I will very soon and keep this thread up to date.

Cheers

amitchandak
Super User
Super User

@cocolinho , based on what I got. You can get table like

 

except(Summarize(filter(Table, Table[availabilty]="yes" , Table[competitor] ="X"), Table[availabilty]),
Summarize(filter(Table, Table[availabilty]="yes" , Table[competitor] ="Y"), Table[availabilty]))

 

You can use it var table in a measure

 

Please provide your feedback comments and advice for new videos
Tutorial Series Dax Vs SQL Direct Query PBI Tips
Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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.