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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
BruceNewsom
Regular Visitor

Last status change in period

Hi,

I have a history table of RAG statuses and I want to report the last status recorded in each period. (or prior if no status recorded in the period). [RAG] is a text field containing "R", "A", or "G".

 

I am using the following measure:

Last_RAG = Calculate(max(History[RAG]), REMOVEFILTERS(),History[Modified Date] <= SELECTEDVALUE('Calendar'[Period]) , History[Project_Id] = SELECTEDVALUE('Project Status'[ID]))
 
But of course this gives me the maximum value recorded so selects R rather than A or G if more than one status happens to be recorded in the same period.  I want the last status that was reported up to the end of the period.

After reading through posts I found this thread
 with a reply by @Greg_Deckler that looked like it would work but doesn't seem to do it for me.  Here's how I modified the code:
Last_RAG =
    VAR _LastDate =
    CALCULATE(
        MAXX(
            FILTER('Calendar',[Date]<= SELECTEDVALUE('Calendar'[Period])),
            [Date]
        )
        ,REMOVEFILTERS())
        VAR _Result = MINX(FILTER(History, [Modified Date] = _LastDate), History[RAG])
        RETURN _Result
1 REPLY 1
HotChilli
Super User
Super User

Sample data and please show the desired result please.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

Top Solution Authors