Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Count/CountA counting wrong category

This is such a simple problem that I have spent HOURS trying to solve with no avail. I have a table with plenty of categories, say A, B, C, D, etc. I have a measure that Counts values in column A,...
  • v-alq-msft's avatar
    5 years ago

    Hi, Anonymous 

     

    Based on your description, I assume that you want to filter by player and get win% for each player. I created data to reproduce your scenario. The pbix file is attached in the end.

    Table:

     

    Names(a calculated table):

    Names = 
    DISTINCT(
        UNION(
            DISTINCT('Table'[Winner's Name]),
            DISTINCT('Table'[Loser's Name])
        )
    )

     

    You may create a measure as below.

    Win % = 
    var result = 
    DIVIDE(
        COUNTROWS(
            FILTER(
                ALL('Table'),
                [Winner's Name]=SELECTEDVALUE(Names[Name])
            )
        ),
        COUNTROWS(
            FILTER(
                ALL('Table'),
                OR(
                    [Winner's Name]=SELECTEDVALUE(Names[Name]),
                    [Loser's Name]=SELECTEDVALUE(Names[Name])
                )
            )
        )
    )
    return
    IF(
        ISBLANK(result),
        0,
        result
    )

     

    Result:

     

    Best Regards

    Allan

     

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