Forum Discussion
Return Most Recent Entry In Summary Table
Reposting after tidying up previous post.
In the table below, I have duplicate entries. I am only interested in the most recent entry, as per the "Finish Time" column. In my summary table, I am only interested to see the "Work Order No" and the "Status". The only two status entries I am interested in is "Complete" and "Incomplete".
| Work Order No | Resource Name | Start Time | Finish Time | Time on Site - Decimal | Status |
| 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 |
My Current DAX:
Table =
SUMMARIZE (
'Aeromark Data',
'Aeromark Data'[Work Order No],
"Status",
CALCULATE (
MAX ( 'Aeromark Data'[Status] ),
FILTER (
'Aeromark Data',
'Aeromark Data'[Finish Time] = MAX ( 'Aeromark Data'[Finish Time] )
)
)
)
This returns the most recent entry:
| Work Order No | Status |
| 4507101 | As Per Lead Engineer Jobsheet |
I need to tweak this code for it to exclude the status "As Per Lead Engineer Jobsheet" - not interested in it. I was thinking about MAX - 1 ... however, I can have a case where I have "As Per Lead Engineer Jobsheet" back-to-back etc.
I appreciate any help on this please.
3 Replies
- some_bihCommunity Champion
Hi Anonymous one possible solution: create new table Test as following
If this post helps, accept as solution to help other members find it more quickly. Kudos appreciated.Test=
VAR __max_finish_date = [MaxFinish] --calculating max finish time
VAR __summarize_table_temp =
SELECTCOLUMNS (
FILTER (
SUMMARIZE (
'Aeromark Data',
'Aeromark Data'[Work Order No],
'Aeromark Data'[Resource Name],
'Aeromark Data'[Start Time],
'Aeromark Data'[Finish Time],
'Aeromark Data'[Time on Site - Decimal],
'Aeromark Data'[Status]
),
'Aeromark Data'[Status] = "Complete"
|| 'Aeromark Data'[Status] = "Incomplete"
&& 'Aeromark Data'[Finish Time] = __max_finish_date
),
"work Order No", 'Aeromark Data'[Work Order No],
"Status", 'Aeromark Data'[Status]
)
RETURN
__summarize_table_temp- AnonymousNot applicable
Hi,
Thanks, this doesn't return anything
I get 'The value for 'MaxFinish' cannot be determined. Either the column doesn't exist, or there is no current row for this column.'
- some_bihCommunity Champion
Hi Anonymous
I would say, as I remember, [MaxFinish] should be measure like below. Please create one
MaxFinish=MAX ( 'Aeromark Data'[Finish Time] )