Hello community,
I need some advice and/or help regarding some data I am trying to parse and add that data to a new column when some condition matches.
Input Data
| Record ID | Prefix | Base | Suffix | External Part Action | Action | Part Number | External Part Number |
| AA12345 | A1CRT | 20A001 | EA | U | Replace Part | A1CRT-20A001-EA | 1AB122135E |
| AA12345 | A1CRT | 20A001 | EB | N | Add Part | A1CRT-20A001-EB | 1AB122135F |
| BA98765 | 45ART | 1020 | CA | U | Replace Part | 45ART-1020-CA | 3323330226 |
| BA98765 | 45ART | 1020 | CA | F | Add Part | 45ART-1020-CA | 3323330226 |
| BA98765 | 45ART | 1020 | CA | U | Replace Part | 45ART-1020-CA | 3323330226 |
| BA98765 | 45ART | 1020 | CA | U | Replace Part | 45ART-1020-CA | 3323330226 |
| CA45678 | 96MRT | ANC123 | BA | U | Replace Part | 96MRT-ANC123-BA | 9AB445567H |
| CA45678 | 96MRT | ANC123 | BBW | F | Add Part | 96MRT-ANC123-BBW | 9AB445567I |
Output Data
| Record ID | Prefix | Base | Suffix | External Part Action | Action | Part Number | External Part Number | Replaces Part Number |
| AA12345 | A1CRT | 20A001 | EA | U | Replace Part | A1CRT-20A001-EA | 1AB122135E | |
| AA12345 | A1CRT | 20A001 | EB | N | Add Part | A1CRT-20A001-EB | 1AB122135F | A1CRT-20A001-EA |
| BA98765 | 45ART | 1020 | CA | U | Replace Part | 45ART-1020-CA | 3323330226 | |
| BA98765 | 45ART | 1020 | CA | F | Add Part | 45ART-1020-CA | 3323330226 | 45ART-1020-CA |
| BA98765 | 45ART | 1020 | CA | U | Replace Part | 45ART-1020-CA | 3323330226 | |
| BA98765 | 45ART | 1020 | CA | U | Replace Part | 45ART-1020-CA | 3323330226 | |
| CA45678 | 96MRT | ANC123 | BA | U | Replace Part | 96MRT-ANC123-BA | 9AB445567H | |
| CA45678 | 96MRT | ANC123 | BBW | F | Add Part | 96MRT-ANC123-BBW | 9AB445567I | 96MRT-ANC123-BA |
The data from the Input table is being parsed from XML files and Record ID is the value present in the File Name and also a unique identifier in the XML.
Now, let us consider Record ID - AA12345 and I need to build a logic where we are able to create a new column called "Replaces Part Number" based on the value in "External Action" column.
If Record ID between two records are same and External Action is different. In this case, if External Action is "U" for the first record and External Action is "N" for the second record and External Part Number for action "N" is a sequence of the part number in comparison to the part number with action "U".
Another scenario is where the Add Part action will be "F" instead of "N" and the External Part numbers for both of them might be same or different like the above scenario. Examples of these are present in the above table, the scenario with the same Part Number is the Record ID - BA98765 and different part number is with Record ID - CA45678
Can someone help me with solving this logic and the workflow attached has the Expected Input and Output data?