Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Distinct count + Display the right class

Hello there 🙂 I have the next scenario: - I have one table with multiple columns, but the relevant ones here are:   Test          ID 1               1 1               2 1               3 1  ...
  • v-alq-msft's avatar
    5 years ago

    Hi, Anonymous 

     

    Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

    Table:

     

    You may create a measure as below.

    Re = 
    var tab = 
    SUMMARIZE(
        'Table',
        'Table'[Test],
        "Result",
        IF(
            [Test]=1,
            CALCULATE(
                DISTINCTCOUNT('Table'[ID]),
                FILTER(
                    ALLEXCEPT('Table','Table'[Test]),
                    NOT([ID] in 
                    CALCULATETABLE(
                        DISTINCT('Table'[ID]),
                        FILTER(
                            ALL('Table'),
                            [Test]=2
                        )
                    )
                    )
                )
            ),
            DISTINCTCOUNT('Table'[ID])
        )
    )
    return
    SUMX(
        tab,
        [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.