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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
joshua1990
Post Prodigy
Post Prodigy

Determine Last State

Hello everyone!

 

I would like to determine the last tracked status within a specific systematic.

So, I have this table:

Date RequestedItemType1Type2ValueStateDate FinishedOrder
01.01.2020AAA12AB50095 100
015.01.2020AAA26AC60010001.02.2020101

 

Now I would like to determine the last state for each order where "Type1" = 6 and "Type2" = AC.

How would you build that measure?

2 REPLIES 2
stevedep
Memorable Member
Memorable Member

Hi,

The below code should do the trick.

___GetLastState = 
var _maxdate = CALCULATE(MAX('Table'[Date Requested]), FILTER(ALL('Table'), 'Table'[Item] = SELECTEDVALUE('Table'[Item]) && 'Table'[Type1] = 6 && 'Table'[Type2] = "AC" ))
return
CALCULATE(MAX('Table'[State]), FILTER(ALL('Table'), 'Table'[Item] = SELECTEDVALUE('Table'[Item]) && 'Table'[Date Requested] = _maxdate))

 

Link to the file here

 

I recorded a video while creating the measure, hopefully, this helps in building an understanding of how to approach such a challenge. 

 

Please accept as a solution if so. Thumbs up for the effort is appreciated.

 

Kind regards, 

 

 

Steve. 

CNENFRNL
Community Champion
Community Champion

Hi, @joshua1990 , you may try this measure

 

Latest Status = MAXX( FILTER(SysLog, SysLog[Type1] = 6 && SysLog[Type2] = "AC"), SysLog[State] )

 


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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