Forum Discussion
Return correct status according to most recent entry.
I have a summary table that I want to just see order numbers in this example "4507101" and next to it a status eg "Complete or Incomplete". For these work order numbers I have a number of entries as you can see below, I am only interested in the most recent one, as per the date/time in column 4.
The next issue is, if the most recent entry has the status "As Per Lead Engineer Jobsheet", I'm not interested in this. I want it to return the most recent "Complete" or "Incomplete".
I was thinking of MAX - 1 date, but I could have back to back "As Per Lead Engineer Jobsheet".
| 4507101 | R Tuck | 11/05/2023 08:28:00 | 11/05/2023 13:51:00 | 5.383333 | As Per Lead Engineer Jobsheet |
| 4507101 | E Defew | 11/05/2023 10:44:00 | 11/05/2023 13:37:00 | 2.883333 | Complete |
| 4507101 | E Defew | 11/05/2023 08:00:00 | 11/05/2023 10:44:00 | 2.733333 | Incomplete |
| 4507101 | R Tuck | 10/05/2023 08:26:00 | 10/05/2023 14:49:00 | 6.383333 | As Per Lead Engineer Jobsheet |
| 4507101 | E Defew | 10/05/2023 09:56:00 | 10/05/2023 14:44:00 | 4.8 | Incomplete |
| 4507101 | J Dixon | 10/05/2023 09:52:00 | 10/05/2023 12:02:00 | 2.166667 | As Per Lead Engineer Jobsheet |
So far I have the DAX:
I do see a value:
Tested with the latest code option:
Column = var ord_num = 'Table'[Work Order No] VAR dt = CALCULATE ( MAX ( 'Table'[Finish Time] ), 'Table'[status] <> "As Per Lead Engineer Jobsheet", 'Table'[Work Order No] = ord_num, ALL('Table') ) RETURN IF( 'Table'[Finish Time] = dt && 'Table'[status] <> "As Per Lead Engineer Jobsheet", 'Table'[Status])
18 Replies
- AnonymousNot applicable
I reposted this after cleaning it up, but I can't seem to see the new post and don't see the option to delete this one.
- ERD
Community Champion
Anonymous , you can try this measure:
Measure = VAR dt = CALCULATE ( MAX ( 'Table'[Finish Time] ), 'Table'[status] <> "As Per Lead Engineer Jobsheet", ALL ( 'Table'[Finish Time] ) ) VAR last_status = CALCULATE ( MAX ( 'Table'[status] ), 'Table'[Finish Time] = dt ) RETURN last_status- AnonymousNot applicable
Hi,
This works in terms of getting rid of "As Per Lead Engineer Jobsheet" thank you.
However, it does not eliminate duplicates. So if I have two "Incomplete" for the same order number on different dates, it returns both results. I'm only interested in the most recent incomplete.
- ERD
Community Champion
Hi, I don't know what's your resulting visual, you can try this:
Measure = VAR dt = CALCULATE ( MAX ( 'Table'[Finish Time] ), 'Table'[status] <> "As Per Lead Engineer Jobsheet", ALL('Table') ) VAR last_status = CALCULATE ( MAX ( 'Table'[status] ), 'Table'[Finish Time] = dt ) RETURN IF ( MAX ( 'Table'[Finish Time] ) = dt, last_status )