Forum Discussion
Create a Merged Deadline and Service History Table
Hi all - I have 2 tables that I need to connect or merge. One is a list of all my assets (table: Covered Products) under contract with their Name (unique), Contract Start and End Dates, a Service Frequency and its Installed Product Id (please note that this Id can occur on multiple names).
Then I have my work order table which has Work Order name (unique), Component Id (this is the same as Installed Product Id) and a service date.
What I need to do is generate a list of deadlines for each Name under Covered Products using frequency as those deadlines (this is either 6 or 12), so Start Date + Frequency (months) = 1st Deadline and so on until the contract end date has been reached.
Then I need to look up to the Work Orders table to find all Service Dates where the Component matches Installed Product Id and whether each deadline has a service before it.
Below are 2 sample tables:
| Name | Frequency | Installed Product ID | Start Date | End Date |
| SCPN-300001 | 12 | az770337348 | 1/1/2021 | 1/1/2026 |
| SCPN-300002 | 12 | az147125002 | 6/1/2021 | 6/1/2024 |
| SCPN-300003 | 12 | az678258801 | 1/1/2022 | 1/1/2027 |
| SCPN-300004 | 12 | az755285236 | 6/1/2022 | 6/1/2026 |
| SCPN-300005 | 6 | az709679783 | 1/1/2023 | 1/1/2026 |
| SCPN-300006 | 12 | az828845604 | 6/1/2023 | 6/1/2026 |
| SCPN-300007 | 12 | az844448390 | 1/1/2024 | 1/1/2029 |
| SCPN-300008 | 6 | az330111770 | 6/1/2024 | 6/1/2029 |
| SCPN-300009 | 12 | az420329397 | 1/1/2025 | 1/1/2028 |
| SCPN-300010 | 12 | az229703231 | 6/1/2025 | 6/1/2029 |
Work Orders:
| Work Order Name | Component Id | Start Date | End Date | Service Date |
| WO-400008 | az147125002 | 6/1/2021 | 6/1/2024 | 5/31/2024 |
| WO-400003 | az229703231 | 6/1/2025 | 6/1/2029 | 9/8/2028 |
| WO-400005 | az229703231 | 6/1/2025 | 6/1/2029 | 7/20/2026 |
| WO-400023 | az229703231 | 6/1/2025 | 6/1/2029 | 12/16/2025 |
| WO-400024 | az229703231 | 6/1/2025 | 6/1/2029 | 5/4/2026 |
| WO-400007 | az330111770 | 6/1/2024 | 6/1/2029 | 7/17/2026 |
| WO-400014 | az330111770 | 6/1/2024 | 6/1/2029 | 10/31/2028 |
| WO-400025 | az330111770 | 6/1/2024 | 6/1/2029 | 4/14/2027 |
| WO-400001 | az420329397 | 1/1/2025 | 1/1/2028 | 5/22/2025 |
| WO-400009 | az420329397 | 1/1/2025 | 1/1/2028 | 7/26/2027 |
| WO-400011 | az420329397 | 1/1/2025 | 1/1/2028 | 6/23/2026 |
| WO-400020 | az420329397 | 1/1/2025 | 1/1/2028 | 9/8/2026 |
| WO-400016 | az678258801 | 1/1/2022 | 1/1/2027 | 10/19/2024 |
| WO-400019 | az678258801 | 1/1/2022 | 1/1/2027 | 1/23/2024 |
| WO-400022 | az678258801 | 1/1/2022 | 1/1/2027 | 8/30/2022 |
| WO-400012 | az709679783 | 1/1/2023 | 1/1/2026 | 8/10/2023 |
| WO-400017 | az709679783 | 1/1/2023 | 1/1/2026 | 12/11/2023 |
| WO-400018 | az709679783 | 1/1/2023 | 1/1/2026 | 12/22/2024 |
| WO-400002 | az755285236 | 6/1/2022 | 6/1/2026 | 4/25/2025 |
| WO-400015 | az755285236 | 6/1/2022 | 6/1/2026 | 4/5/2024 |
| WO-400013 | az770337348 | 1/1/2021 | 1/1/2026 | 8/14/2021 |
| WO-400006 | az828845604 | 6/1/2023 | 6/1/2026 | 9/5/2024 |
| WO-400004 | az844448390 | 1/1/2024 | 1/1/2029 | 9/22/2027 |
| WO-400010 | az844448390 | 1/1/2024 | 1/1/2029 | 3/11/2025 |
| WO-400021 | az844448390 | 1/1/2024 | 1/1/2029 | 12/23/2024 |
And in addition, I would need some way to disntinguish between a service being late or on time. For instance with a deadline of 31/12/2025 but I did the service on 15/01/2026 - this should not count as the 2026 deadline.
Expected Result:
| Product Name | Frequency | Start Date | End Date | Deadline # | Deadline Date | WO Number | Service Date | On Time? |
| SCPN-300001 | 12 | 1/1/2021 | 1/1/2026 | 1 | 31/12/2021 | WO-123456 | 15/12/2021 | Yes |
| SCPN-300001 | 12 | 1/1/2021 | 1/1/2026 | 2 | 31/12/2022 | WO-123457 | 30/11/2022 | Yes |
| SCPN-300001 | 12 | 1/1/2021 | 1/1/2026 | 3 | 31/12/2023 | WO-123458 | 15/01/2024 | No |
| SCPN-300001 | 12 | 1/1/2021 | 1/1/2026 | 4 | 31/12/2024 | WO-123459 | 10/12/2024 | Yes |
| SCPN-300001 | 12 | 1/1/2021 | 1/1/2026 | 5 | 31/12/2025 | WO-123460 |
How did you generate the last 3 columns of the desired table? I do not see the entries under these columns in the Work Orders table.
8 Replies
- lbendlin
Super User
Here's your deadline explosion for the assets table.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dZI9CsMwDEbv4jkl+rWkuXspdAwZeo2evk5TIscQD+ZD5vFky8tSXvfn48bQFpapILXt/TEDZmPxrTTjTECYsZZ16kFKEMWQdC/VBP9RBpATrOak7tBpKKMNoHStqpIrcU1NJx9b1e1o5yCqhTmnha+vWFPo5C5afz3UBC+E1oHSlnNAaiRjDKAfnTIDIraR9A95xJGLFAoBU3BYWjSjn0GEBImifQDibnR6Mq5f", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, Frequency = _t, #"Installed Product ID" = _t, #"Start Date" = _t, #"End Date" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Start Date", type date}, {"End Date", type date}, {"Frequency", Int64.Type}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Deadline", (k)=> List.Generate(()=>Date.AddMonths(k[Start Date],k[Frequency]),each _ <= k[End Date], each Date.AddMonths(_,k[Frequency]))), #"Expanded Deadline" = Table.ExpandListColumn(#"Added Custom", "Deadline"), #"Changed Type1" = Table.TransformColumnTypes(#"Expanded Deadline",{{"Deadline", type date}}) in #"Changed Type1"You can now compare that against the service dates. Not sure what your expected outcome is for the sample data you provided.
- quincy_p
Advocate I
Have updated original post with expected result
- Ashish_Mathur
Super User
Hi,
Based on the 2 tables which you have shared, show the expected result very clearly.
- quincy_p
Advocate I
Here would be an example - using the matching Id to find the associated work orders completed against each product name. Then to see if there is a service date within each service period, completed on time.
Hope that Helps
Product Name Frequency Start Date End Date Deadline # Deadline Date WO Number Service Date On Time? SCPN-300001 12 1/1/2021 1/1/2026 1 31/12/2021 WO-123456 15/12/2021 Yes SCPN-300001 12 1/1/2021 1/1/2026 2 31/12/2022 WO-123457 30/11/2022 Yes SCPN-300001 12 1/1/2021 1/1/2026 3 31/12/2023 WO-123458 15/01/2024 No SCPN-300001 12 1/1/2021 1/1/2026 4 31/12/2024 WO-123459 10/12/2024 Yes SCPN-300001 12 1/1/2021 1/1/2026 5 31/12/2025 WO-123460 - Ashish_Mathur
Super User
How did you generate the last 3 columns of the desired table? I do not see the entries under these columns in the Work Orders table.