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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

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

 

idstart dateend datecategorychangesn changes
910011/07/201905/07/2019category 1  
910011/10/201911/10/2019category 2x1
910002/12/201929/11/2019category 2  
222202/11/198230/09/1990category 1x 
222201/10/199030/09/1993category 2x 
222201/10/199328/02/1994category 3x3
369801/03/200431/12/2005category 5  
369801/01/200631/12/9999category 5 0
1 ACCEPTED SOLUTION
v-luwang-msft
Community Support
Community Support

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 ()
    )

vluwangmsft_0-1663062767376.png

 

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

 

Best Regards,
Lucien

View solution in original post

6 REPLIES 6
v-luwang-msft
Community Support
Community Support

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 ()
    )

vluwangmsft_0-1663062767376.png

 

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

 

Best Regards,
Lucien

Anonymous
Not applicable

Thanks for your response @v-luwang-msft .
but the changes column doesn't exist in my data model. how can i create it?

Hi @Anonymous ,

Use the following dax to create a new column:

change1 = 
VAR rank1 =
    RANKX (
        FILTER ( ALL ( 'Table' ), 'Table'[id] = EARLIER ( 'Table'[id] ) ),
        'Table'[end date],
        ,
        ASC,
        DENSE
    )
RETURN
    IF (
        rank1 <> 1
            && CALCULATE (
                MAX ( 'Table'[category] ),
                FILTER (
                    ALL ( 'Table' ),
                    'Table'[id] = EARLIER ( 'Table'[id] )
                        && RANKX (
                            FILTER ( ALL ( 'Table' ), 'Table'[id] = EARLIER ( 'Table'[id] ) ),
                            'Table'[end date],
                            ,
                            ASC,
                            DENSE
                        ) = rank1 - 1
                )
            ) <> 'Table'[category],
        "x",
        BLANK ()
    )

 

Output:(And I think the first id=2222 not need "x" )

vluwangmsft_0-1663292820295.png

 

 

Best Regards

Lucien

Anonymous
Not applicable

Hello,
Thanks for your response @lbendlin .
only changes of a new category are important.
any idea how to do this?

Do a distinct count of categories per user and subtract 1

lbendlin
Super User
Super User

User 2222 only changed category twice, not three times.

 

Do you want to report on any changes or only on changes to a new category?

 

Let's say the third line of 9100 would be category 1.  Does this now count as two changes?

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.