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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Find last changed value and date

Hello,

 

I have a table with historical data with ID, Status and Date. I would like to add 2 additional columns and can show what is the last "changed value" and last changed date for the same ID. Here is the example:

 

IDStatusDate
AActive9/15/2019
AActive9/18/2019
AInactive9/20/2019
AActive9/21/2019
BActive9/15/2019
BInactive9/18/2019
BActive9/20/2019
BActive9/21/2019
BActive9/25/2019
CInactive9/15/2019
CMaintenance9/18/2019
CInactive9/20/2019
CActive9/21/2019
CInactive9/25/2019


I want to have the result liks this:

IDStatusDateLast changed valueLast Changed Date
AActive9/15/2019  
AActive9/18/2019  
AInactive9/20/2019Active9/18/2019
AActive9/21/2019Inactive9/20/2019
BActive9/15/2019  
BInactive9/18/2019Active9/15/2019
BActive9/20/2019Inactive9/18/2019
BActive9/21/2019Inactive9/18/2019
BActive9/25/2019Inactive9/18/2019
CInactive9/15/2019  
CMaintenance9/18/2019Inactive9/15/2019
CInactive9/20/2019Maintenance9/18/2019
CActive9/21/2019Inactive9/20/2019
CInactive9/25/2019Active9/21/2019

 

Any ideas is appreciated, thank you.

1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

Hello @Anonymous 

Two calculated columns will get what you are looking for I think.

First we figure out the [Last Changed Date]

Last Changed Date = 
VAR _Status = 'Table'[Status]
VAR _Date = 'Table'[Date]
RETURN
CALCULATE(
    MAX ( 'Table'[Date] ),
    ALLEXCEPT ( 'Table', 'Table'[ID] ),
    'Table'[Date] < _Date,
    'Table'[Status] <> _Status
)

Then we can use that to get the [Last Changed Status]

Last Changed Status = 
VAR _LastChangeDate = 'Table'[Last Changed Date]
RETURN
CALCULATE(
    MAX ( 'Table'[Status] ),
    ALLEXCEPT ( 'Table', 'Table'[ID] ),
    'Table'[Date] = _LastChangeDate
)

LastChangeDateStatus.jpg

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

Try, if this can help

https://community.powerbi.com/t5/Desktop/highest-value-by-category/td-p/428758

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
jdbuchanan71
Super User
Super User

Hello @Anonymous 

Two calculated columns will get what you are looking for I think.

First we figure out the [Last Changed Date]

Last Changed Date = 
VAR _Status = 'Table'[Status]
VAR _Date = 'Table'[Date]
RETURN
CALCULATE(
    MAX ( 'Table'[Date] ),
    ALLEXCEPT ( 'Table', 'Table'[ID] ),
    'Table'[Date] < _Date,
    'Table'[Status] <> _Status
)

Then we can use that to get the [Last Changed Status]

Last Changed Status = 
VAR _LastChangeDate = 'Table'[Last Changed Date]
RETURN
CALCULATE(
    MAX ( 'Table'[Status] ),
    ALLEXCEPT ( 'Table', 'Table'[ID] ),
    'Table'[Date] = _LastChangeDate
)

LastChangeDateStatus.jpg

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 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.