Forum Discussion
DAX help: most recent event
- 2 years ago
Hi,
This M code works
let Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content], #"Grouped Rows" = Table.Group(Source, {"Customer Confirmation Number", "Delivery Confirmation Number"}, {{"Count", each Table.Max(_,{"Last Event Date","Last Event Time"})}}), #"Expanded Count" = Table.ExpandRecordColumn(#"Grouped Rows", "Count", {"Manifest Date", "Receive Date", "Last Event Date", "Last Event Time", "Last Event Description"}, {"Manifest Date", "Receive Date", "Last Event Date", "Last Event Time", "Last Event Description"}), #"Changed Type" = Table.TransformColumnTypes(#"Expanded Count",{{"Last Event Date", type date}, {"Last Event Time", type time}}) in #"Changed Type"Hope this helps.
Hi MJAGUSIAK ,
You can try formula like below:
Last Status =
VAR CustomerNumber =
MAX ( 'DHL Status'[Delivery Confirmation Number] )
RETURN
CALCULATE (
MAXX (
FILTER (
ALL ( 'DHL Status' ),
'DHL Status'[Delivery Confirmation Number] = CustomerNumber
),
'DHL Status'[Last Event Date] + 'DHL Status'[Last Event Time]
),
FILTER (
'DHL Status',
'DHL Status'[Delivery Confirmation Number] = CustomerNumber
)
)
Best Regards,
Adamk Kong
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
This formula works for giving me the last date and time that is in the data.
I need to use the Delivery Confirmation Number and look for the most recent date and then take that most recent date and display whatever is in the column for Last Event Description.
Basically, I am wanting to override any previously seen status codes and only use the most recent status in the data for that particular customer tracking number.
- lbendlin2 years ago
Super User
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information or anything not related to the issue or question.
If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216
Please show the expected outcome based on the sample data you provided.
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523- MJAGUSIAK2 years ago
Helper I
Customer Confirmation Number Delivery Confirmation Number Manifest Date Receive Date Last Event Date Last Event Time Last Event Description '78510745 '9274890326139904723314 1/25/2024 5:07 1/22/2024 19:02 1/26/2024 6:10:00 AM OUT FOR DELIVERY '78542345 '9274890326139904739452 1/25/2024 5:07 1/23/2024 18:58 1/26/2024 6:21:00 AM OUT FOR DELIVERY '78510884 '9274890326139904736161 1/25/2024 5:07 1/23/2024 18:58 1/26/2024 6:55:00 AM OUT FOR DELIVERY '78541001 '9261290326139904737940 1/25/2024 1:08 1/23/2024 18:59 1/26/2024 6:10:00 AM OUT FOR DELIVERY '78510745 '9274890326139904723314 1/25/2024 5:07 1/22/2024 19:02 1/26/2024 6:10:00 AM DELIVERED '78542345 '9274890326139904739452 1/25/2024 5:07 1/23/2024 18:58 1/26/2024 6:21:00 AM DELIVERED '78510884 '9274890326139904736161 1/25/2024 5:07 1/23/2024 18:58 1/26/2024 6:55:00 AM DELIVERED '78541001 '9261290326139904737940 1/25/2024 1:08 1/23/2024 18:59 1/26/2024 6:10:00 AM DELIVERED
- Ashish_Mathur2 years ago
Super User
Hi,
Share data in a format that can be pasted in an MS Excel file. Show the expected result as well.
- MJAGUSIAK2 years ago
Helper I
Customer Confirmation Number Delivery Confirmation Number Manifest Date Receive Date Last Event Date Last Event Time Last Event Description '78510745 '9274890326139904723314 1/25/2024 5:07 1/22/2024 19:02 1/26/2024 6:10:00 AM OUT FOR DELIVERY '78542345 '9274890326139904739452 1/25/2024 5:07 1/23/2024 18:58 1/26/2024 6:21:00 AM OUT FOR DELIVERY '78510884 '9274890326139904736161 1/25/2024 5:07 1/23/2024 18:58 1/26/2024 6:55:00 AM OUT FOR DELIVERY '78541001 '9261290326139904737940 1/25/2024 1:08 1/23/2024 18:59 1/26/2024 6:10:00 AM OUT FOR DELIVERY '78510745 '9274890326139904723314 1/25/2024 5:07 1/22/2024 19:02 1/26/2024 6:10:00 AM DELIVERED '78542345 '9274890326139904739452 1/25/2024 5:07 1/23/2024 18:58 1/26/2024 6:21:00 AM DELIVERED '78510884 '9274890326139904736161 1/25/2024 5:07 1/23/2024 18:58 1/26/2024 6:55:00 AM DELIVERED '78541001 '9261290326139904737940 1/25/2024 1:08 1/23/2024 18:59 1/26/2024 6:10:00 AM DELIVERED - Ashish_Mathur2 years ago
Super User
Hi,
Based on the Table that you have shared, please also show the expected result.