Skip to content

Instantly share code, notes, and snippets.

@cbaragao
Created August 7, 2026 02:45
Show Gist options
  • Select an option

  • Save cbaragao/99bce8820cb37ec15efc9499d7a11542 to your computer and use it in GitHub Desktop.

Select an option

Save cbaragao/99bce8820cb37ec15efc9499d7a11542 to your computer and use it in GitHub Desktop.
Excel Challenge 1037
let
Source = Excel.CurrentWorkbook(){[Name = "Data"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source, {{"Data", type text}}),
Base = Table.AddColumn(
#"Changed Type",
"Answer",
each Text.Lower(RemoveChars([Data], true, true, false, false)),
type text
),
Process = Table.AddColumn(
Base,
"List",
each
let
base = List.Distinct(Base[Answer]),
val = [Answer],
alpha = Text.Combine(List.Sort(Splitter.SplitTextByRepeatedLengths(1)(val)), ""),
remove = List.Select(base, each _ <> val),
tx = List.Transform(remove, each Splitter.SplitTextByRepeatedLengths(1)(_)),
sort = List.Transform(tx, each List.Sort(_)),
combine = List.Transform(sort, each Text.Combine(_, "")),
select = List.Transform(combine, each _ = alpha),
zip = List.Zip({remove, select}),
matches = List.Select(zip, each _{1} = true),
tx_matches = List.Transform(matches, each _{0}),
final =
if List.Count(tx_matches) < 1 then
null
else
Text.Combine(List.Sort(List.Combine({{val}, tx_matches})), " | ")
in
final,
type text
),
#"Filtered Rows" = Table.SelectRows(Process, each ([List] <> null)),
#"Removed Other Columns" = Table.SelectColumns(#"Filtered Rows", {"List"}),
#"Removed Duplicates" = Table.Distinct(#"Removed Other Columns"),
#"Sorted Rows" = Table.Sort(#"Removed Duplicates", {{"List", Order.Ascending}})
in
#"Sorted Rows"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment