user20414
user20414

Reputation: 3

Using a query with multiple results in a subsequent query - Google Sheets

I have a query that returns 2 or more results.

I want to be able to pass ALL the results, one-by-one to power another query. I decided to embed the queries.

=IFERROR(QUERY('Sheet1'!A1:J36,"SELECT J,B,C,D,E,F,G,H WHERE J Contains '" & B11 & "' AND B='" & QUERY('Sheet2'!$A$3:$AR$103,"SELECT D WHERE " & VLOOKUP($B11,'Test Sheet'!$A$33:$B$43,2,FALSE) & "='Yes' AND (AR='High' OR AR='Low') ORDER BY AH desc" ,0) & "' ORDER BY G desc" ,1),"No Results")

The query as a whole runs successfully, however only the first result of the initial query is passed to the outer query. This means I don't get all the matches I am expecting.

Is there a way of accomplishing this?

Upvotes: 0

Views: 497

Answers (1)

MattKing
MattKing

Reputation: 7783

I think this is what your'e trying to do, on the MK.Help tab in cell A74.

=IFERROR(QUERY('Interventions V0.2'!A1:J39,"SELECT J,B,C,D,E,F,G,H WHERE J Contains '" & B11 & "' AND B matches'" & JOIN("|",QUERY('Biomarker Ref. Sheet (Static)'!$A$3:$AR$103,"SELECT D WHERE " & VLOOKUP($B11,'Test Sheet'!$A$33:$B$43,2,FALSE) & "='Yes' AND (AR='High' OR AR='Low')",0)) & "' ORDER BY G desc" ,1),"No Results")

Upvotes: 1

Related Questions