英文:
(Google Sheets) How can I reference a cell value (string) in the 2nd parameter of the query function?
问题
=QUERY(Sheet1!A:E, "select Col4 where Col3 = " & A2, 0)
英文:
Imagine I have a string value at cell A2 = "name".
I want to use query in such a way that I can reference the value of the cell in the second parameter like this:
=QUERY(Sheet1!A:E, "select Col4 where Col3 = 'A2' ", 0)
But of course, that won't work because since the parameter is inside '', the function reads it as a string (as A2 instead of name).
How can I reference the cell itself so that it will read the value of the cell instead of 'A2'?
答案1
得分: 2
您可以尝试:
=QUERY({Sheet1!A:E}, "select Col4 where Col3 = '"&A2&"' ", 0)
或
=QUERY(Sheet1!A:E, "select D where C = '"&A2&"' ", 0)
或
=filter(Sheet1!D:D,Sheet1!C:C=A2)
英文:
<!-- language-all: js -->
You may try:
=QUERY({Sheet1!A:E}, "select Col4 where Col3 = '"&A2&"' ", 0)
OR
=QUERY(Sheet1!A:E, "select D where C = '"&A2&"' ", 0)
OR
=filter(Sheet1!D:D,Sheet1!C:C=A2)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论