I have the following association :
dat = <|"(1)" -> <|"A" -> -1, "B" -> -1, "C" -> -1|>,
"a" -> <|"A" -> 1, "B" -> -1, "C" -> -1|>,
"b" -> <|"A" -> -1, "B" -> 1, "C" -> -1|>,
"ab" -> <|"A" -> 1, "B" -> 1, "C" -> -1|>,
"c" -> <|"A" -> -1, "B" -> -1, "C" -> 1|>,
"ac" -> <|"A" -> 1, "B" -> -1, "C" -> 1|>,
"bc" -> <|"A" -> -1, "B" -> 1, "C" -> 1|>,
"abc" -> <|"A" -> 1, "B" -> 1, "C" -> 1|>|>
Which can be transformed into a Dataset as :
ds = Dataset@dat
I would like to perform multiplications of combinaisons of several columns. The columns which must be multiplied are given by index :
header = Flatten@DeleteDuplicates@Keys@Values@dat;
index = Select[Subsets[header], Length@# >= 2 &];
(*index = {{"A", "B"}, {"A", "C"}, {"B", "C"}, {"A", "B", "C"}} <- these columns must be multiplied together*)
I have found on this post a way to achieve that for column A and B (index[[1]]) :
i = 1;
ds[All, Append[#, StringJoin@index[[i]] -> Times @@ {#A, #B}] &]
Now I'd like to apply this on each element of index. I've unsuccessfully tried
ds[All, Append[#,StringJoin@index[[i]] -> Times @@ Map[Slot, index[[i]]]] &]
with the hope that I can then iterate over index...

Times @@ Through[Map[Lookup, cols][#]]withTimes @@ Lookup[cols][#]– kglr Jan 10 '24 at 11:28