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
mlee
Frequent Visitor

Displaying winning pct% against each opponent

Hello. I'm new to Power BI and am not sure how to tackle the following problem.

 

I have a csv file which contains the following columns (name1, name2, winner, fieldcondition).

 

Example rows are: John, Susan, John, Dry and Phil, Greg, Greg, Wet. 

 

What I'd like to show are a couple of things:

 

1. I'd like to show the winning pct% for each player against each opponent. For example, I'd like to display John's winnng pct% against Susan and then his winning pct% against Phil, and so on. 

2. After I get the above working I'd like to add in another factor where I'd like to see for example Phil's winning pct% against each opponent but in this case flip between dry and wet field conditions. For example, Phil's winning pct% against Susan is 75% when dry but drops to 50% when wet.

 

Is this sort of thing doable in Power BI? 

 

Thanks,

 

Mike

1 ACCEPTED SOLUTION
v-sihou-msft
Microsoft Employee
Microsoft Employee

@mlee

 

In this scenario, your source table is for match level. Since you want to analysis player data, I suggest you duplicate your dataset, swap name1 and name2 columns in duplicated dataset, then combine two datasets together. So for each match, it will have two entries, one for player 1, the other for player 2. You dataset can be like:

 

Player Opponent winner field condition

John, Susan, John, Dry

Susan, John, John, Dry

 

Add a win tag column like:

 

isWin = IF(Table[Player]=Table[winner],1,0)

To calculate the win rate versus some player, you can use ALLEXCEPT() to have your calculation group on both play and opponent.

 

 

Win Rate =
CALCULATE (
    COUNTROWS ( Table ),
    ALLEXCEPT ( Table, Table[Player], Table[Opponent] )
)
    / CALCULATE (
        COUNTROWS ( Table ),
        ALLEXCEPT ( Table, Table[Player], Table[Opponent] ),
        FILTER ( Table, Table[isWin] = 1 )
    )

 

If you also want analysis based on fieldcondition, just add that column into ALLEXCEPT() function.

 

Win Rate =
CALCULATE (
    COUNTROWS ( Table ),
    ALLEXCEPT ( Table, Table[Player], Table[Opponent], Table[fieldcondition] )
)
    / CALCULATE (
        COUNTROWS ( Table ),
        ALLEXCEPT ( Table, Table[Player], Table[Opponent], Table[fieldcondition] ),
        FILTER ( Table, Table[isWin] = 1 )
    )

Regards,

 

View solution in original post

1 REPLY 1
v-sihou-msft
Microsoft Employee
Microsoft Employee

@mlee

 

In this scenario, your source table is for match level. Since you want to analysis player data, I suggest you duplicate your dataset, swap name1 and name2 columns in duplicated dataset, then combine two datasets together. So for each match, it will have two entries, one for player 1, the other for player 2. You dataset can be like:

 

Player Opponent winner field condition

John, Susan, John, Dry

Susan, John, John, Dry

 

Add a win tag column like:

 

isWin = IF(Table[Player]=Table[winner],1,0)

To calculate the win rate versus some player, you can use ALLEXCEPT() to have your calculation group on both play and opponent.

 

 

Win Rate =
CALCULATE (
    COUNTROWS ( Table ),
    ALLEXCEPT ( Table, Table[Player], Table[Opponent] )
)
    / CALCULATE (
        COUNTROWS ( Table ),
        ALLEXCEPT ( Table, Table[Player], Table[Opponent] ),
        FILTER ( Table, Table[isWin] = 1 )
    )

 

If you also want analysis based on fieldcondition, just add that column into ALLEXCEPT() function.

 

Win Rate =
CALCULATE (
    COUNTROWS ( Table ),
    ALLEXCEPT ( Table, Table[Player], Table[Opponent], Table[fieldcondition] )
)
    / CALCULATE (
        COUNTROWS ( Table ),
        ALLEXCEPT ( Table, Table[Player], Table[Opponent], Table[fieldcondition] ),
        FILTER ( Table, Table[isWin] = 1 )
    )

Regards,

 

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.