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
jkaufman
Regular Visitor

DAX Create column LAST status based on MAX date

I'd like to add a few fields that calculate the Last Status based on the ID. That is, for the 'ID' = 54EBA584-0FDA-4766-B3B1-7FC0709C92BA the max 'Status Date' is 10/29/2018. So I would like a column populated with 10/29/2018 for all records with 'ID' = 54EBA584-0FDA-4766-B3B1-7FC0709C92BA.

 

Furthermore, and more importantly, I'd like a column that returns the latest 'Status Outcome' correlated to the MAX 'Status Date'. So for the same example a column with 'Last_Status' populated with ACTIVE for all records with 'ID' = 54EBA584-0FDA-4766-B3B1-7FC0709C92BA.

 

Is this possible to do in DAX?

 

ID       Status Date       Status      Status Outcome

54EBA584-0FDA-4766-B3B1-7FC0709C92BA8/15/2018PendingP01
54EBA584-0FDA-4766-B3B1-7FC0709C92BA8/20/2018PendingP02
54EBA584-0FDA-4766-B3B1-7FC0709C92BA8/28/2018PendingP03
54EBA584-0FDA-4766-B3B1-7FC0709C92BA9/3/2018ActiveA01
54EBA584-0FDA-4766-B3B1-7FC0709C92BA10/1/2018ActiveA01
54EBA584-0FDA-4766-B3B1-7FC0709C92BA10/29/2018ActiveA01
162E0BD7-E850-4F9C-BA38-3540348A87788/22/2018PendingP01
162E0BD7-E850-4F9C-BA38-3540348A87788/27/2018PendingP02
162E0BD7-E850-4F9C-BA38-3540348A87789/4/2018PendingP03
162E0BD7-E850-4F9C-BA38-3540348A87789/5/2018CancelledC05
8B876A64-6F52-48A5-8FF3-EBF3040DF15E8/24/2018PendingP01
8B876A64-6F52-48A5-8FF3-EBF3040DF15E8/29/2018PendingP02
8B876A64-6F52-48A5-8FF3-EBF3040DF15E9/8/2018PendingP03
8B876A64-6F52-48A5-8FF3-EBF3040DF15E9/16/2018ActiveA01
8B876A64-6F52-48A5-8FF3-EBF3040DF15E10/14/2018ActiveA01
8B8716564-6F52-48A5-8FF3-EBF3040GD238/30/2018PendingP01
3156fsd64-6F52-48A5-8FF3-EBF3040GD2568/31/2018PendingP01
3156fsd64-6F52-48A5-8FF3-EBF3040GD2579/3/2018PendingP01
3156fsd64-6F52-48A5-8FF3-EBF3040GD2579/6/2018PendingP02
3156fsd64-6F52-48A5-8FF3-EBF3040GD2589/5/2018PendingP01
1 ACCEPTED SOLUTION
v-yuta-msft
Community Support
Community Support

Hi jkaufman,

 

To achieve your requirement, create two calculate column using DAX as below:

Max Status Date = CALCULATE(MAX(Table1[Status Date]), ALLEXCEPT(Table1, Table1[ID]))

Result = CALCULATE(MAX(Table1[Status]), FILTER(ALLEXCEPT(Table1, Table1[ID]), Table1[Status Date] = Table1[Max Status Date]))

 捕获.PNG

 

Regards,

Jimmy Tao

View solution in original post

6 REPLIES 6
v-yuta-msft
Community Support
Community Support

Hi jkaufman,

 

To achieve your requirement, create two calculate column using DAX as below:

Max Status Date = CALCULATE(MAX(Table1[Status Date]), ALLEXCEPT(Table1, Table1[ID]))

Result = CALCULATE(MAX(Table1[Status]), FILTER(ALLEXCEPT(Table1, Table1[ID]), Table1[Status Date] = Table1[Max Status Date]))

 捕获.PNG

 

Regards,

Jimmy Tao

Anonymous
Not applicable

I've been wracking my brain trying to figure out how to do this!! Thank you so much for your solution!

My code is pretty similar to yours, except I didn't use the Filter(AllExcept) function. I just used the following code. May I ask what does the Filter(AllExcept) does for this code, and why wouldn't it work without it?

Again, thank you so much.

CALCULATE(MAX(Table1[Status]), Table1[Status Date] = Table1[Max Status Date])

 

Thanks for your solution! Please help count people by the last status.  

Hi,

Share some data, explain the question and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

 

I faced a similar problem, but the solution failed with the external filter. This Doesn’t work when we apply an external or explicit filter on a Status date.

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.