0

Link to Sheet: https://docs.google.com/spreadsheets/d/1_40L74r4Y-inibZw7aplE38DDzdszrFgBMX3HU_Bsf0/edit?usp=sharing

I have a raw data sheet with responses from a questionaire. From this sheet, I want to spread out the answers over multiple sheets, depending on client & project, so that we get one shipping list for each project.

In the Shipping List I added A1 as the project number and A2 as the Client name to refer to. Now I want to list all emails from the raw data sheet, that also match A1 and A2 as project & client. Also I need to fetch the "Amount Prdt" (Product_Pick_RAW!A) and "Products" (Product_Pick_RAW!B:V). All Product info should be joined together with commas as a seperator.

Status Quo: I picked out the emails with: =IFERROR(INDEX(Product_Pick_RAW!$A2:$AC; MATCH($A$1;Product_Pick_RAW!X:X;0);23);"FEHLER")

Amount Prdt: =FILTER(Product_Pick_RAW!A:A;Product_Pick_RAW!Y:Y=TRIM($A$2);Product_Pick_RAW!X:X=TRIM($A$1);Product_Pick_RAW!W:W=TRIM(E4))

Products: =INDEX(REGEXREPLACE(TRIM(FLATTEN(QUERY(TRANSPOSE(FILTER(IF(Product_Pick_RAW!B:U="";;Product_Pick_RAW!B:U&",");Product_Pick_RAW!Y:Y=$A$2;Product_Pick_RAW!X:X=$A$1;Product_Pick_RAW!W:W=E4));;9^9))); ",$";))

Problem: Now I realized specifically the email solution this is not usable for an array case and picking out multiple results.

Does anyone know a solution for this?

Thanks!

alto97
  • 15
  • 5

1 Answers1

1

SUGGESTION

Perhaps you can try this method:

==UPDATE==

For Email on E column that's separated by row:

=QUERY(Product_Pick_RAW!W2:Y,"SELECT W where Y='"&$A$2&"' AND X='"&$A$1&"'")

==UPDATE==

For Amount Prdt on H column that's separated by row:

=QUERY(Product_Pick_RAW!A2:Y, "SELECT A WHERE Y = '"&$A$2&"' AND X = '"&A1&"'")

==UPDATE==

For Products on I column, you can try this custom function FINDLINKS by adding this script below as a bound script on your spreadsheet:

function FINDLINKS(range, project, client) {
  var container = [];
  for(x=0; x<range.length; x++){
    if(range[x][22].includes(project) & range[x][23].includes(client)){
      container.push([range[x][0]+"\n"+
                      range[x][1]+"\n"+
                      range[x][2]+"\n"+
                      range[x][3]+"\n"+
                      range[x][4]+"\n"+
                      range[x][5]+"\n"+
                      range[x][6]+"\n"+
                      range[x][7]+"\n"+
                      range[x][8]+"\n"+
                      range[x][9]+"\n"+
                      range[x][10]+"\n"+
                      range[x][11]+"\n"+
                      range[x][12]+"\n"+
                      range[x][13]+"\n"+
                      range[x][14]+"\n"+
                      range[x][15]+"\n"+
                      range[x][16]+"\n"+
                      range[x][17]+"\n"+
                      range[x][18]+"\n"+
                      range[x][19]]);
    }
  }
  return container;
}

Then you can use FINDLINKS custom function on column I like this:

=ARRAYFORMULA(TRIM(FINDLINKS(Product_Pick_RAW!B2:Y9;$A$1;$A$2)))

Sample Result:

enter image description here

SputnikDrunk2
  • 3,398
  • 1
  • 5
  • 17
  • Jay. G: That worked quite well. Is it possible to have each one in their own row though? So the first email, with relating product count and product links and then the second one in the next row? – alto97 Oct 19 '21 at 07:48
  • Thanks for your comment. As for the email, with relating product count, it is possible by solely using the query function (see my updated answer). However, as for the concatenated product links for each on each product count (`Amount Prdt`) & email, I can only think of using query via arrayformula to get each product links, but unfortunately, it is not supported upon further research [see](https://webapps.stackexchange.com/a/97314). – SputnikDrunk2 Oct 19 '21 at 15:54
  • Are you willing to use a custom formula for the product links using apps script instead? – SputnikDrunk2 Oct 19 '21 at 15:57
  • Thanks for the update. I implemented the formulas and they work great. I installed the Apps Script Tool and created a new project with this formula. I have two issues remaining: 1) When running the script, I receive this error: TypeError: Cannot read property 'length' of undefined FINDLINKS @ Product Links Script.gs:3 – alto97 Oct 20 '21 at 09:32
  • 2) I'm not sure I've correctly connected the Script to the sheet. Is there a way to make sure the script is now bound to the sheet? – alto97 Oct 20 '21 at 10:58
  • @alto97 It seems you're running the function from the Apps Script editor, thus, you're getting the `TypeError: Cannot read property 'length' of undefined FINDLINKS.` It is expected because there's no data from the `range` yet. For it to work, you need to put this custom formula: `=ARRAYFORMULA(REGEXREPLACE(FINDLINKS(Product_Pick_RAW!B2:Y9,$A$1,$A$2), "^(?:[\t ]*(?:\r?\n|\r))+", ""))` on the `I4` cell for the `FINDLINKS` custom formula to work. – SputnikDrunk2 Oct 20 '21 at 15:05
  • I added it to the cell and ran it again. It still shows the same error. – alto97 Oct 20 '21 at 16:47
  • Could you try it on your end? – alto97 Oct 20 '21 at 16:58
  • It looks like the formula should use semi-colons instead of commas. So it should be like `=ARRAYFORMULA(TRIM(FINDLINKS(Product_Pick_RAW!B2:Y9;$A$1;$A$2)))`. I have also simplified the formula. I have found this reference https://support.google.com/docs/thread/4271054/change-semicolon-to-commas-in-formulas?hl=en&msgid=4273368 – SputnikDrunk2 Oct 20 '21 at 17:36
  • @alto97 I have adjusted the custom formula on your shared sheet file. Hopefully it works on your end – SputnikDrunk2 Oct 20 '21 at 17:49
  • Great, It works now! Thank you so much – alto97 Oct 21 '21 at 06:29