Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
Hi,
this is my initial table:
Symbols |
(*) |
(^) |
(!) |
(~) |
I want to create a list of all the combinations of these 4 symbols.
The order of the symbols doesn't matter, its just the combination that matters.
eg, (*)(!) = (!)(*)
also, I want to exclude repeating, eg:
(*)(*)(*)(!) should just be (*)(!)
So here's my code:
let
Source = Excel.CurrentWorkbook(){[Name="Tbl_symbol"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Symbols", type text}, {"Definition", type text}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1),
#"Added Custom" = Table.AddColumn(#"Added Index", "Custom", each 1),
#"Merged Queries" = Table.NestedJoin(#"Added Custom",{"Custom"},#"Added Custom",{"Custom"},"Added Custom",JoinKind.LeftOuter),
#"Expanded Added Custom" = Table.ExpandTableColumn(#"Merged Queries", "Added Custom", {"Symbols"}, {"Symbols.1"}),
#"Merged Queries1" = Table.NestedJoin(#"Expanded Added Custom",{"Custom"},#"Expanded Added Custom",{"Custom"},"Expanded Added Custom",JoinKind.LeftOuter),
#"Expanded Expanded Added Custom" = Table.ExpandTableColumn(#"Merged Queries1", "Expanded Added Custom", {"Symbols", "Symbols.1"}, {"Symbols.2", "Symbols.1.1"}),
#"Removed Columns" = Table.RemoveColumns(#"Expanded Expanded Added Custom",{"Definition", "Index", "Custom"})
in
#"Removed Columns"
And this is what I get:
I'd like to merge the columns now, but I'm not sure how to ONLY include the column if it is distinct from the existing items. Also, this may not manage the whole (*)(!) being the same as (!)(*). One step at a time, perhaps! My initial merge queries could be optimised for a better outcome?
Thanks so much in advance for your help.
Solved! Go to Solution.
It sounds like you want the set of all possible subsets of these four symbols.
If that's correct, you may be interested in my comment on @smpa01's combinatorics blog post. In particular, you can generate the list of combinations as follows:
let
Source = {"(*)", "(^)", "(!)", "(~)"},
N = List.Count(Source),
Subsets =
List.Transform(
{0..Number.Power(2, N)-1},
(i) => List.Transform(
{0..N-1},
(j) => if Number.Mod(Number.IntegerDivide(i, Number.Power(2, j)), 2) = 1
then Source{j}
else null
)
),
Concatenate = List.Transform(Subsets, each Text.Combine(List.RemoveNulls(_), ""))
in
Concatenate
Output:
It sounds like you want the set of all possible subsets of these four symbols.
If that's correct, you may be interested in my comment on @smpa01's combinatorics blog post. In particular, you can generate the list of combinations as follows:
let
Source = {"(*)", "(^)", "(!)", "(~)"},
N = List.Count(Source),
Subsets =
List.Transform(
{0..Number.Power(2, N)-1},
(i) => List.Transform(
{0..N-1},
(j) => if Number.Mod(Number.IntegerDivide(i, Number.Power(2, j)), 2) = 1
then Source{j}
else null
)
),
Concatenate = List.Transform(Subsets, each Text.Combine(List.RemoveNulls(_), ""))
in
Concatenate
Output:
Excellent! Thank you so very much.
Hmmmm ... perhaps if you showed/provided us the Source and the desired outcome, we may be able to assist you quicker?
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.