Home > Mobile >  Extract Jotform Product Data from Multi Line Cell in Google Sheets
Extract Jotform Product Data from Multi Line Cell in Google Sheets

Time:11-10

I am using Jotform for customers to place quarterly orders, and we then receive this data into a google sheet. Unfortunately Jotform's product list places all the items into one multi-line cell, so when trying to total the number of cases for each item to know how much to order from our suppliers it is difficult to extract the information.

As an example the data we receive would be something like:

Product 1 (Amount: 32.00 USD, Number of cases: 66)
Product 2 (Amount: 16.00 USD, Number of cases: 2)
Product 5 (Amount: 35.00 USD, Number of cases: 3)
Product 6 (Amount: 17.00 USD, Number of cases: 3)
Product 9 (Amount: 13.00 USD, Number of cases: 1)
Product 10 (Amount: 12.00 USD, Number of cases: 4)
Total: 2,361.00 USD

There are 26 products in total, and while they do seem to come in the same order, not all products are present in each order.

I have tried several things with regex, splitting lines by CHAR(10), but can't quite find a simple solution to it. What I would like is an output where I could perhaps create a set of columns for each product and have the number of cases for that product on each row for our customer.

A sample with a small variety of the order lines is enter image description here

Or this formula if all the input is in a single cell

=ArrayFormula({
      {"Products";"Amount";"Number of cases"},
        SPLIT(BYROW({"(. )\(";"\(Amount: (.*) USD,";"Number of cases: (.*)\)"},
              LAMBDA(re, TEXTJOIN("|",1,IFERROR(REGEXEXTRACT(TRANSPOSE(SPLIT(A1, CHAR(10))), ""&re&""))))),"|")})

enter image description here

Update

=ArrayFormula(LAMBDA(rg, QUERY(TRANSPOSE({{"Products";"Amount";"Number of cases"},
        SPLIT(BYROW({"(. )\(";"\(Amount: (.*) USD,";"Number of cases: (.*)\)"},
              LAMBDA(re, TEXTJOIN("|",1,IFERROR(REGEXEXTRACT(QUERY(FLATTEN(TRANSPOSE(SPLIT(rg, CHAR(10))))," where not Col1 contains 'Total:'  "), ""&re&""))))),"|")}), 
                    "Select Col1,sum(Col2),sum(Col3) group by Col1 order by sum(Col2) desc ",1))(B2:B))

enter image description here

Used formulas help
ARRAYFORMULA - SPLIT - BYROW - LAMBDA - TEXTJOIN - IFERROR - REGEXEXTRACT - TRANSPOSE - CHAR - QUERY - FLATTEN - NOT - SUM

  • Related