Separating Lists into new rows

Hi coda community,

I’m using the Shopify + Coda packs, and would like to separate out the orders.

As you can see in the example, order 1150 has 4 line items (split into a delimited list in column “test”.

I want these separated into rows, so each row would read like this (manually typed in)

Can someone help me with this please?

TIA!

hi @Nikki_Donkin

I you would have shared a dummy copy of your problem, I could have worked in that.

See below what I created, we count the number of items in the list and create as many rows as we count items (4 in the first row, 2 in the second row).

the button code

Sequence(1,thisRow.[list with items].split(",").Count()).FormulaMap(To.Addrow(To.ID,thisRow.ID,To.[numbers per row],thisRow.[list with items].Split(",").Nth(CurrentValue)))

hope it helps, best, Christiaan

1 Like

Hey Christiaan, thanks so much for your reply! It works well when I use the two items columns you put, if I try to add in other fields, such as SKU or Quantity, it causes the other columns not to split? What am I missing?

Screenshot 2021-05-17 130949

hi @Nikki_Donkin ,

Glad to read I could be of help.

it is not easy to see from screenshots what might cause the trouble.

When asking the community for help on something like this its always better if you create a sample document that you can share and show us what the problem is and where … with tables, schemata, formulas there is so much detail its easy to spend a lot of effort chasing the wrong thing.

Anyway, I tried to recreate your problem and solved it by adding split() as you can see on the screenshot below.

I am a bit surprised that the pack you used caused this problem.

Cheers, Christiaan

1 Like

Hi Christiaan,

Thanks again for coming back to me! I’m not sure what I’m doing wrong, as far as I can tell I’ve written it just like you have. I’ve created a dummy spreadsheet now (apologies for not doing that first)

Thank you!

hi @Nikki_Donkin

Thanks for the doc, that helps indeed :wink:

What I did it checking the columns to see how many items they contained and most of them only 1 instead of the 10 you see To keep it simple I duplicated each column and created a split version (could also be done in the code in the button, but as such you see better what happens). In the button I refer to this split version.

I left the ‘test’ out

Sequence(1, thisRow.[Order Number].split(",").Count())
  .FormulaMap(
    Addrow(
      [Orders Separated],
      [Orders Separated].[Line Item],thisRow.[Line Items Split].Nth(CurrentValue),
      [Orders Separated].Order,
      thisRow.[Order Number Split].Nth(CurrentValue),
            [Orders Separated].SKU,
      thisRow.[SKU Split].Nth(CurrentValue),
      [Orders Separated].Quantity,
      thisRow.[Volume Split].Nth(CurrentValue)
    )
  ) 

Does this work for you?

Best, Christiaan

1 Like

That does, thanks so much for your help!