QUERY syntax using cell reference

后端 未结 8 1712
隐瞒了意图╮
隐瞒了意图╮ 2020-12-23 21:46

I\'m having trouble figuring out a fairly simple QUERY statement in Google Spreadsheets. I\'m trying to use a cell reference instead of static values and I\'m running into t

8条回答
  •  旧巷少年郎
    2020-12-23 21:49

    I know this is an old thread but I had the same question as the OP and found the answer:

    You are nearly there, the way you can include cell references in query language is to wrap the entire thing in speech marks. Because the whole query is written in speech marks you will need to alternate between ' and " as shown below.

    What you would need is this:

    =QUERY(Responses!B1:I, "Select B where G contains '"& B1 &"' ")
    

    If you then wanted to refer to multiple cells you could add more like this

    =QUERY(Responses!B1:I, "Select B where G contains '"& B1 &"' and G contains '"& B2 &"' ")
    

    The above would filter down your results further based on the contents of B1 and B2.

提交回复
热议问题