There are lots of ways to solve this problem. We brainstormed a few:
Write a network of buttons - e.g. iterate through each group of fruits (small, medium, large) and add them each to a table in a certain order to generate all the combinations
Map to a number - e.g. if there are two options for each size, then you could translate a binary number like 001, 010, 011, ...
Use a recursive formula - where each formula iterates through each size with a base case when there are no more values to be added
Calculate it algorithmically from a row number - i.e. ensure there are N rows (# of small fruits * # of medium fruits * # of large fruits), and use each row's row number to describe each unique combination.
This solution mostly builds on the last idea.
Step 1: Calculate the number of rows we need, and ensure they exist
This is the first line of the solution:
Loading…
These are the formulas:
This is then hooked up to an automation that will push the button whenever the Fruits Table changes.
Step 2: Given a Row Number, generate a unique combination
Before getting to the math part, we have to deal with the fact that RowID() is a great formula, but it is monotonically increasing - so if you delete rows, you will have gaps. So you'll notice that the
table has a column called N which gives a ordinal number to each row with no gaps:
Next we need to generate the unique combination for each value of N. The basic idea is to do it numerically first (with columns i, j, and k) and then use those as indexes to pick the i-th, j-th, and k-th fruits from each of the small, medium, and large sets. So for the math-y parts, here's how i, j, and k are calculated.
After that, the Small, Medium, and Large columns are simple indexed lookups
One quick sidenote that you might have noticed is that you can get a particular "cell value" from a cell by typing @rowname.columnname. This can be handy for lookup values like @Small.Count
Putting it all together
Here's the same view with the underlying columns unhidden