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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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