EN VI

Google-sheets - Google Sheet - QUERY SELECT does not handle apostrophe in WHERE CLAUSE?

2024-03-15 21:00:04
Google-sheets - Google Sheet - QUERY SELECT does not handle apostrophe in WHERE CLAUSE

I have this Google Sheet report.

The problem is when my client name has an apostrophe, it breaks the formula.

=IFERROR(INDEX(QUERY(Projects!$1:$2018, "select sum(G) where A='"&A2&"'"),2), 0)

https://docs.google.com/spreadsheets/d/16UOU5iMwieHjVmV81TdK3_emxyj-wFqXa8u5Nia7Wkg/edit#gid=1016414243

Do you know how I can change this ?

Thanks.

Solution:

Try with triple double quotes to escape those single quotes you have:

=IFERROR(INDEX(QUERY(Projects!$1:$2018, "select sum(G) where A="""&A2&""""),2), 0)

enter image description here

You can also use SUMIF, and don't worry about how the values are written:

=SUMIF(Projects!A:A,A2,Projects!G:G)

enter image description here

Answer

Login


Forgot Your Password?

Create Account


Lost your password? Please enter your email address. You will receive a link to create a new password.

Reset Password

Back to login