Finding all combinations to a summed value

cerberus1845

New Member
Joined
Nov 14, 2023
Messages
23
Office Version
  1. 2021
Platform
  1. Windows
  2. MacOS
I'm looking for some help on the following problem I have. I have an excel workbook which has 2 columns - one column is the description and the other column is a decimal value. I then have a series of summed values (totals) that i want to work out what combinations of values in the two columns could result in the total.

I've found the following custom function approach - which gets me somewhere to where i want to be: Find all combinations of numbers that equal a given sum in Excel

This produces the output of the combinations - but the output isn't in the original decimal format (it drops the 2 decimal places) and in an ideal world I would like either the descriptions returned that correspond to the values or the numbers returned as a decimal (or both i.e. descriptions and their decimal values which equal the target cell) - but this is a bit out of my skill set and I'm hoping someone on here might be able to help me please?
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
yes i do! :)

If it is the case, test this (adjust ranges):

Excel Formula:
=LET(
numbers,A1:A10,
total,B1,
combinations,TEXTAFTER(DROP(REDUCE("",TOCOL(numbers),LAMBDA(a,b,VSTACK(a,a&" | "&b))),1)," | ",1),
sum,DROP(REDUCE(0,TOCOL(numbers),LAMBDA(a,b,VSTACK(a,a+b))),1),
FILTER(combinations,sum=total))

It should return a list of numbers that add to the total; if it works, it might be further elaborated to identify which numbers and descriptions are relevant.
 
Upvote 1
hi - y
If it is the case, test this (adjust ranges):

Excel Formula:
=LET(
numbers,A1:A10,
total,B1,
combinations,TEXTAFTER(DROP(REDUCE("",TOCOL(numbers),LAMBDA(a,b,VSTACK(a,a&" | "&b))),1)," | ",1),
sum,DROP(REDUCE(0,TOCOL(numbers),LAMBDA(a,b,VSTACK(a,a+b))),1),
FILTER(combinations,sum=total))

It should return a list of numbers that add to the total; if it works, it might be further elaborated to identify which numbers and descriptions are relevant.
yes this works in terms of values!!! :)
 
Upvote 0
If it is the case, test this (adjust ranges):

Excel Formula:
=LET(
numbers,A1:A10,
total,B1,
combinations,TEXTAFTER(DROP(REDUCE("",TOCOL(numbers),LAMBDA(a,b,VSTACK(a,a&" | "&b))),1)," | ",1),
sum,DROP(REDUCE(0,TOCOL(numbers),LAMBDA(a,b,VSTACK(a,a+b))),1),
FILTER(combinations,sum=total))

It should return a list of numbers that add to the total; if it works, it might be further elaborated to identify which numbers and descriptions are relevant.
actually when I've expanded the table/List i receive a #NUM! error (it was working for a smaller set of data 10 rows - I've expanded this to 55 and receive this error) - I've tested incrementally and it seems to work up until 20 items and then errors - any ideas how to resolve?
 
Last edited:
Upvote 0
Ah, indeed, there are too many combinations. I guess it would be better to test what @jkpieterse proposed?
that solution didn't really make sense? - couldn't work out how it would apply in this scenario?

it's a pity there is a limitation on it as what you proposed worked really well (out of curiosity - how would you adapt it to include the descriptions to the left of the values)
 
Upvote 0
One trick you could use is to use a separate area in which you multiply all amounts by 100, use that function and then divide its results by 100.
thanks for your reply.. how would this actually work in terms of changes i would need to make?
 
Upvote 0

Forum statistics

Threads
1,222,117
Messages
6,164,056
Members
451,870
Latest member
Nikhil excel

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top