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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Is there an alternative for this conditional column solution?

Hi,

 

I am trying to answer an analysis question for the Online Chess Game dataset on https://www.mavenanalytics.io/data-playground

 

I am trying to answer the below query,

"What percentage of games are won by the player with the higher rating?"

 

The ratings are presented like below,

MHoque_0-1657122406091.png

 

I have been able to output the winners into a conditional column (higher/lower) via power query (transform data)  - I can then calculate the percentages with measures into something like this,

MHoque_1-1657123186877.png

This has worked for me however I am aware that this can impact performance as this increases the size of the overall file.

What would be the best practice in this instance? Is there a way to work around this with measures?

 

Thanks in advance for any assistance/advice,

Miz

 

1 ACCEPTED SOLUTION
AntonioM
Solution Sage
Solution Sage

You could write that as a measure, something like 

Higher % =
VAR higher =
    SUMX (
        Table,
        IF (
            ( Table[Winner] = "White"
                && Table[white_rating] > Table[black_rating] )
                || ( Table[Winner] = "Black"
                && Table[white_rating] < Table[black_rating] ),
            1
        )
    )
RETURN
    DIVIDE ( higher, [Total Games] )

and then format that as %

View solution in original post

5 REPLIES 5
AntonioM
Solution Sage
Solution Sage

You could write that as a measure, something like 

Higher % =
VAR higher =
    SUMX (
        Table,
        IF (
            ( Table[Winner] = "White"
                && Table[white_rating] > Table[black_rating] )
                || ( Table[Winner] = "Black"
                && Table[white_rating] < Table[black_rating] ),
            1
        )
    )
RETURN
    DIVIDE ( higher, [Total Games] )

and then format that as %

Anonymous
Not applicable

Thank you AntonioM - that worked 😊

 

A follow up query,

 

If I have the winner column (winner) and player rating columns (white_rating, black_rating) stored in separate dimension tables. How would I reference both tables working with a measure like the above?

 

Thanks again - I'll mark it as a solution!

You shoud be able to use RELATED and then sum over the fact table

 

SUMX (
        FactTable,
        IF (
            ( RELATED(DimTable1[Winner]) = "White"
                && RELATED(DimTable2[white_rating]) > RELATED(DimTable2[black_rating]) )
                || ( RELATED(DimTable1[Winner] = "Black"
                && RELATED(DimTable2[white_rating]) < RELATED(DimTable2[black_rating]) ),
            1
        )
    )

 

Anonymous
Not applicable

That worked thank you (just needed to add a closing bracket after "black").

 

I am still relatively new to Power BI/DAX but you have taught me quite a bit about using RELATED and IF - Thanks again!

Yes - I missed that one.

 

No worries!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.