Notifications
Clear all
Power Query
3
Posts
2
Users
0
Reactions
37
Views
Topic starter
I would like to ask you help about the possibility calculate subset sum in power query.
My problem is to find the addends that sumup to a specific result. For example I have a list of 20 numbers and a list o 3 numbers (that represent the sum of the numbers in the first list). I have to find witch number composes each sum in in the list of sums (3 sum groups). I hope you managed to understand my problem and I hope it is feasible in PowerQuery.
I tried to generate this code with ChatGPT (it works but is is too resource intensive, (I feel that there are more lighter solutions ):
let // Definizione della lista originale numbers = {1, 2, 3},
// Bufferizzazione della lista originale bufferedNumbers = List.Buffer(numbers),
// Generazione di tutti i sottoinsiemi allSubsets = List.Accumulate(bufferedNumbers, { {} }, (state, current) => state & List.Transform(state, each _ & {current})),
// Output: Tutti i sottoinsiemi output = allSubsets in output
Thank you very much and I look forward to hearing from you
AG
Posted : 08/02/2024 10:20 am
Can you upload a file with some example data and the expected result. It's difficult to visualise what you need.
Posted : 08/02/2024 10:35 am
Topic starter
Dear Alan,
I send to you an excel file with the expected result.
I have to match for each date in the list on the left the numbers that add up in the lists on the right.
I used colours to give a more easily view to the result. I hope it's clearer now.
Thank you
Kind regards
AG
Posted : 08/02/2024 11:30 am