Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

count category changes per user

Hello How can i count how many times the user changes category? How to calculate the value of n changes? ps the changes column doesn't exist in my table thanks   id start date end date ca...
  • v-luwang-msft's avatar
    3 years ago

    Hi Anonymous ,

    Pls use the below dax to create a new column:

    n change1 =
    VAR maxdate =
        CALCULATE ( MAX ( 'Table'[start date] ), ALLEXCEPT ( 'Table', 'Table'[id] ) )
    RETURN
        IF (
            'Table'[start date] = maxdate,
            IF (
                CALCULATE (
                    COUNT ( 'Table'[id] ),
                    ALLEXCEPT ( 'Table', 'Table'[id] ),
                    'Table'[changes] = "x"
                )
                    = BLANK (),
                0,
                CALCULATE (
                    COUNT ( 'Table'[id] ),
                    ALLEXCEPT ( 'Table', 'Table'[id] ),
                    'Table'[changes] = "x"
                )
            ),
            BLANK ()
        )
    

     

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

     

    Best Regards,
    Lucien