I have a table with text in columns TXT1, TXT2
The texts are separated by a comma and are in a different order in each column
In the first step I split the texts into a list
In the next step, I wrote a function that checks which text in the first list does not exist in the second list – if all the text exists, the function returns {}, which means that there is a match
Now I want to build a double loop
The outer loop changes each time the list I want to check in TXT1 and the inner loop runs all the lists in TXT2
I’m probably not passing the values to the function correctly and am getting an error
This is my code
”
let
TXT1 = {“RV0003,19915,26966”,
“RVG002,19923,26966”,
“NO”,
“NO”,
“NO”},
TXT2 = {"NO",
“NO”,
“RV0002,19915,19923,26966”,
“RV0003,19915,19923,26966”,
“RVG002,19915,19923,26966”},
TableFromColumns = Table.FromColumns({TXT1, TXT2}, {"TXT1", "TXT2"}),
Step_Split_TXT1 = Table.AddColumn(TableFromColumns, "Split_TXT1", each Text.Split([TXT1], ",")),
Step_Split_TXT2 = Table.AddColumn(Step_Split_TXT1, "Split_TXT2", each Text.Split([TXT2], ",")),
AddIndex = Table.AddIndexColumn(Step_Split_TXT2, "Index", 0, 1),
AddMatchResult = Table.AddColumn(AddIndex, "MatchResult", each List.Accumulate([Split_TXT2], "NO", (state, current) => if state = "YES" then "YES" else CheckMatch([Split_TXT1]{[Index]}, current)))
in
AddMatchResult
”
this is the function
”
let
CheckMatch = (list1 as list, list2 as list) =>
let
Difference = List.Difference(list1, list2),
MatchResult = if List.IsEmpty(Difference) then “YES” else “NO”
in
MatchResult
in
CheckMatch
”
Column A | Column B |
---|---|
Cell 1 | Cell 2 |
Cell 3 | Cell 4 |