The key is to add an index before self merging, then use a column to filter out index2 <= index
try_combinations3.xlsx
TBLCOUNTRY:
Code:
let
Fonte = #"LISTCOUNTRY",
#"Personalização Adicionada" = Table.AddColumn(Fonte, "COLLISTCOUNTRY", each LISTCOUNTRY),
#"Expanded COLLISTCOUNTRY1" = Table.ExpandTableColumn(#"Personalização Adicionada", "COLLISTCOUNTRY", {"COUNTRY", "Index"}, {"COUNTRY2", "Index2"}),
#"Added Custom" = Table.AddColumn(#"Expanded COLLISTCOUNTRY1", "Custom", each if [Index2] <=[Index] then 0 else 1),
#"Filtered Rows" = Table.SelectRows(#"Added Custom", each ([Custom] = 1)),
#"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Index", "Index2", "Custom"})
in
#"Removed Columns"
LISTCOUNTRY:
Code:
let
Fonte = Excel.CurrentWorkbook(){[Name="Tabela1"]}[Content],
#"Added Index" = Table.AddIndexColumn(Fonte, "Index", 1, 1)
in
#"Added Index"
Bookmarks