How to Coda your Shopify Pack
Distributing values over rows using a button
I am not a Shopify user, but I solved two times more or less the same question in the community. The question asked is:
How can we distribute values (bought goods) living in one cell because one order number over several rows.
The issue looks like this:
The solution is not a difficult one once you understand a few basics. First I show how I solved it:
AddRow() takes the values living in a row and places them in a new row, most often in a different table, but not necessarily. You can add rows to your ‘source table’ as well. In our example we have a helper table that receives the information.
If we simply add a row, we have all the line items still in one row, but now in a new table. This does not help.
To distribute the line items, we should point out that each item in the list should be treated as a row. We do so by first counting the items, second making a list of numbers from 1 up to the count (like 1,2,3,4,5) via Sequence. Third we start evaluating this list of numbers one by one via a
FormulaMap() and relating them in our last step to the items living in the cell by adding the function
Nth(). This function is about the position of each item in a list. We have two lists:
- the list of numbers via
- the items living in the cell
We combine these two lists and relate each item in the list ‘line items’ to a (virtual) number by adding
Nth(). Doing so we instruct Coda to treat each line item as a separate row. Since this function lives in a button, our final step is to create a button outside the table that pushes all the buttons at ones.
Maybe the Coda pack maker responsible for this Shopify Pack can add a button and some instructions on how to make better use of the data you just got in. As long as this does not happen, the presented solution might be your friend.
I hope you enjoyed this article. If you have questions feel free to reach out. Though this article is for free, my work (including advice) won’t be, but there is always room for a chat to see what can be done. Besides you find my (for free) contributions to the Coda Community and on Twitter
My name is Christiaan and I support SMB with calculations (budgets and planning) and I prefer using Coda to get the job done.
Not to forget: the Coda Community provides great insights for free once you add a sample doc. Paid consulting is often not the way to proceed.