Forum Discussion

rigosakh's avatar
rigosakh
Frequent Visitor
8 years ago
Solved

Unique count measure

  Hi all,   I'm migrating from Excel to Power BI and struggling with turning some excel calculations into DAX format. A screenshot that sort of shows how the data is structured is below.   The ...
  • v-huizhn-msft's avatar
    8 years ago

    Hi rigosakh,

    I reproduce your scenario and get expected result. Please follow the steps below.

    1. In desktop, please create a calculated column using the formula, I assume the table name as 'Table2'.

    Column =
    RANKX (
        FILTER (
            Table2,
            Table2[PK] = EARLIER ( Table2[PK] )
                && Table2[Value] = EARLIER ( Table2[Value] )
        ),
        Table2[Time],
        ,
        ASC,
        DENSE
    )
    


    2. Create another calculted column to get Unique count based on the column above.

    Unique Count =
    IF (
        Table2[Value] = BLANK (),
        0,
        IF (
            Table2[Column]
                = CALCULATE ( MIN ( Table2[Column] ), ALLEXCEPT ( Table2, Table2[Value] ) ),
            1,
            0
        )
    )
    


    You will get desired result as follows.



    Best Regards,
    Angelia