Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
I am trying to find the most recent event in my PBI.
Here are my column names and I need to find the last status update under "Last Event Description". I created a new column that combines the last event day and time.
Customer Confirmation Number | Delivery Confirmation Number | Manifest Date | Receive Date | Last Event Date | Last Event Time | Last Event Description | Zip or Postal Code |
Please let me know how I should go about getting this most recent status.
I tried to use the following but its not pulling back the latest status:
Solved! Go to Solution.
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.
Hi,
Share data in a format that can be pasted in an MS Excel file. Show the expected result as well.
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 |
Hi,
Based on the Table that you have shared, please also show the expected result.
Sorry, didnt catch that when I created the sample data. please use below.
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/25/2024 | 6:10:00 AM | OUT FOR DELIVERY |
'78542345 | '9274890326139904739452 | 1/25/2024 5:07 | 1/23/2024 18:58 | 1/25/2024 | 6:21:00 AM | OUT FOR DELIVERY |
'78510884 | '9274890326139904736161 | 1/25/2024 5:07 | 1/23/2024 18:58 | 1/25/2024 | 6:55:00 AM | OUT FOR DELIVERY |
'78541001 | '9261290326139904737940 | 1/25/2024 1:08 | 1/23/2024 18:59 | 1/25/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 |
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 Ashish,
My dev team changed the file for me to use. I need to use the tracking number and the activity date to see the most up to date activity code. I need to see how the M code would be for these columns because I keep getting errors when trying to use the code from above and just insert it into the m code with changing the needed names:
Warehouse Code | Client Name | Carrier Code | Ship Date | Tracking Number | Error Desc from Carrier | Process flag | Activity Code | Activity Date |
73011 | KS DFW | 90000011 | 2024/02/02 | 1ZR637F60107746480 | F | D | 20240205 |
Here is my M code that works right now but is not sorted:
let
Source = SharePoint.Files("https://pfsweb0.sharepoint.com/sites/CarrierTracking/", [ApiVersion = 15]),
#"Filtered Rows" = Table.SelectRows(Source, each ([Folder Path] = "https://pfsweb0.sharepoint.com/sites/CarrierTracking/Web Focus reports/")),
#"Filtered Hidden Files1" = Table.SelectRows(#"Filtered Rows", each [Attributes]?[Hidden]? <> true),
#"Invoke Custom Function1" = Table.AddColumn(#"Filtered Hidden Files1", "Transform File (3)", each #"Transform File (3)"([Content])),
#"Renamed Columns1" = Table.RenameColumns(#"Invoke Custom Function1", {"Name", "Source.Name"}),
#"Removed Other Columns1" = Table.SelectColumns(#"Renamed Columns1", {"Source.Name", "Transform File (3)"}),
#"Expanded Table Column1" = Table.ExpandTableColumn(#"Removed Other Columns1", "Transform File (3)", Table.ColumnNames(#"Transform File (3)"(#"Sample File (3)"))),
#"Changed Type" = Table.TransformColumnTypes(#"Expanded Table Column1",{{"Source.Name", type text}, {"Warehouse Code", Int64.Type}, {"Client Name", type text}, {"Carrier Code", Int64.Type}, {"Ship Date", type date}, {"Tracking Number", type text}, {"Error Desc from Carrier", type any}, {"Process flag", type text}, {"Activity Code", type text}, {"Activity Date", Int64.Type}}),
#"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"Source.Name"})
in
#"Removed Columns"
Cannot understand what you want. Share some data to work with, explain the question and show the expected result.
This worked great. much appreciated.
You are welcome.
It should pull back the data where it is showing only a unique value for Delivery Confirmation Number with the most recent "Last date and time" showing the "last Event Description"
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 | 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 |
9274890326139904723314 has 2 entries and both have the same end date and time. Why shoud the delivered row show up in the result.
The expected result is the following and it should not show back the other rows:
'78541001 | '9261290326139904737940 | 1/25/2024 1:08 | 1/23/2024 18:59 | 1/26/2024 | 6:10:00 AM | DELIVERED |
'78541001 | '9261290326139904737940 | 1/25/2024 1:08 | 1/23/2024 18:59 | 1/26/2024 | 6:10:00 AM | DELIVERED |
Hi,
"Last Event Description" is a column with text entries. So what do you mean by "Find the last status update"? [from your first post]
The data will have entries with duplicates of Delivery Confirmation Numbers whenever the status of the Last Event Description changes. 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.
So if there are duplicate numbers then i need to use the most recent entry to display and use for calculations.
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-...
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/1447...
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 |
Your VAR CustomerNumber returns a table. You may be missing the aggregation function.
A simple way would be to use TOPN(1) and CONCATENATEX.
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
87 | |
83 | |
82 | |
65 | |
49 |
User | Count |
---|---|
135 | |
111 | |
100 | |
65 | |
62 |