All possibilities mixer?

Hello Community!

For the first time this decade, I need your help :laughing:

I’ve been trying to create a kind of “mixer” that could take a list of values and mix them to create all possibilities. I tried some formula mapping but unfortunately couldn’t make it work :confused:

Here’s a simplified version of what I’m trying to build:

Thanks a lot to anyone who can help with this!
Edit: In a perfect world, the same combinations would not come up twice (ex: Apple+Salad, Salad+Apple). If this isn’t possible, I’ll just create a button to clear duplicates after the mixes are created.

Something like this?

Or do you need all possible combinations of 2, 3, 4 etc fruits together?

Thanks for the quick reply @Paul_Danyliuk :slight_smile: I took some time to analyse the puzzle and it seems a bit complicated to work with, especially if I want to have more than 3 types of “fruits”. This would be used to create clothes and marketing campaigns (all ads possibilities with creatives, copy, placements, etc) so the number of parameters could change.

I added a table for the desired outcome to make thing clearer. I made it manually for the sake of the example. Maybe there’s no other way to make it simpler, in this case I’ll have to use the “3 types” model and maybe find a way to get extra values using lookups :thinking:

Again, thanks for your help :pray:

Not totally sure what you exactly need. But you can always implement an action that will iterate however you need, explicitly. Like here:

E.g. if you need to make all combinations of 2 fruit, here’s the steps I’d take:

  1. In your fruits table, make a column where you look up the remaining fruit to match this row with (e.g. thisTable.Filter(CurrentValue.RowID > thisRow.RowID), plus some custom conditional if you only need to match with some fruits and not all)
  2. Implement the loop like in the link above. For each row store current row into a temp cell, and for each remaining fruit put a row with temp cell value and CurrentValue.

I’m so sorry if this wasn’t clear, trying really hard to understand here and not looking to waste your time :grimacing:

I added a table for Categories. This way, if I wanted to add a column for let’s say Spices, I could add a row in the Categories Table and modify the switchif to pull the values from the Spices table (and also modify the formula to calculate possible combinations). Is it possible to create combinations from there?

Alright, here’s one more way to make a list of all combinations, for any number of categories. It takes a recursive approach to calculate the product of thisRow x nextRow and gives you the result in the first row of the table (a list of lists):

At this point it may feel like I’m just flexing — for your specific case it could’ve been done easier. But I want to show a general case solution so that anyone could learn from it.

2 Likes

To achieve your objectives elegantly and with great simplicity, I think you need a splash of data science - like this. And, I believe the only efficient way to create these iterations is to use complex arrays (i.e., tuples).

This underscores the potential benefits for allowing embedded scripting in Coda. Imagine inserting into a section a block for Python, or Javascript. This would be an ideal way to delicately blend data science into Coda apps while allow us to perform complex computations seamlessly inside the document.

Better still (and way off-topic) - imagine a function that allows you to write it in javascript or Python). :wink:

Perhaps there is a way to do this already and if so, it’s just not obvious to me how to approach this other than the API.

1 Like

Thanks a lot to both of you @Paul_Danyliuk @Bill_French, it’s awesome to have the opportunity to learn from experts. Coda wouldn’t be cool without users like you :crazy_face:

2 Likes

Perhaps this is the case with Paul, but I assure you – Coda was way cool long before I arrived here.

2 Likes