Search code examples
arraysif-statementgoogle-sheetsrandomgoogle-query-language

Seeking results of multi conditions in multi data column, but each condition value is just one of many in a single cell of google sheet


Please check the file first. https://docs.google.com/spreadsheets/d/1wYq9BEESpu77wvJzQY1AE4Gmr_PhhaNFSik0ZZt8aD0/edit?usp=sharing My purpose is:

  • Generating idea randomly in "Calendar" sheet base on the "Idea" sheet The concept is:
  • Selecting the condition about Industry & Quality in B1 & B2 in "Calendar" sheet
  • Selecting the time will post on each day of week
  • Then the idea will be shown off based on these conditions. In this case, any cell can has 2+ values.

We can't split values to single columns because those data can be added more value in future.


Solution

  • try:

    =QUERY({RANDARRAY(ROWS(A2:A)), A2:G}, "select Col2 where 9=9 "&
     IF(J11="",," and Col3 contains '"&J11&"' ")&
     IF(J12="",," and Col4 contains '"&J12&"' ")&
     IF(J13="",," and Col5 contains '"&J13&"' ")&
     IF(J14="",," and Col6 contains '"&J14&"' ")&
     IF(J15="",," and Col7 contains '"&J15&"' ")&
     "order by Col1 limit 1")
    

    enter image description here