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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anna_maija
New Member

Mark if status changes per id and date

Hello!

 

I would like to create calculated column (to use as a slicer) when status change by using dax. Here is the example of data.

 

Anna_maija_0-1710413532874.png

 

 

1 ACCEPTED SOLUTION
v-yilong-msft
Community Support
Community Support

Hi @Anna_maija ,
Based on your requirement, here is my answer.

I create a table as you mentioned.

vyilongmsft_0-1710467536472.png

Then I go to the Power Query to insert an Index column.

vyilongmsft_1-1710467592603.png

Then I create an calculated column, here is the DAX code.

StatusChangeFlag =
VAR _PreviousIndex =
    CALCULATE (
        MAX ( 'Table'[Index] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Index] < EARLIER ( 'Table'[Index] ) )
    )
VAR _PreviousStatus =
    CALCULATE (
        SELECTEDVALUE ( 'Table'[Status] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Index] = _PreviousIndex )
    )
RETURN
    IF ( _PreviousStatus <> BLANK () && 'Table'[Status] <> _PreviousStatus, 1 )

Finally, when we change the letter, it will give us a "1".

vyilongmsft_2-1710467750676.png

 

 

 

Best Regards

Yilong Zhou

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

View solution in original post

1 REPLY 1
v-yilong-msft
Community Support
Community Support

Hi @Anna_maija ,
Based on your requirement, here is my answer.

I create a table as you mentioned.

vyilongmsft_0-1710467536472.png

Then I go to the Power Query to insert an Index column.

vyilongmsft_1-1710467592603.png

Then I create an calculated column, here is the DAX code.

StatusChangeFlag =
VAR _PreviousIndex =
    CALCULATE (
        MAX ( 'Table'[Index] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Index] < EARLIER ( 'Table'[Index] ) )
    )
VAR _PreviousStatus =
    CALCULATE (
        SELECTEDVALUE ( 'Table'[Status] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Index] = _PreviousIndex )
    )
RETURN
    IF ( _PreviousStatus <> BLANK () && 'Table'[Status] <> _PreviousStatus, 1 )

Finally, when we change the letter, it will give us a "1".

vyilongmsft_2-1710467750676.png

 

 

 

Best Regards

Yilong Zhou

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

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.