With reference to the question how to remove sum label from query, I have a similar situation.

Where would I put the `LABEL sum(E)` in this formula?

``````=if((\$B2="weekday"), ifna(QUERY('Base Data'!\$A:\$G, "select sum(E) where B = '"&D\$1&"' and G = '"&\$A2&"'",0),"") , "")
``````
• Simon, my apologies! I'm aware that you're new to the site, originally posted this question as an answer, and that answer was closed during the review process (question posted as an answer). You deserve credit for following the advice in the close reason to the letter. You posted a new question referencing the other one. Now it's been closed as a duplicate. The other question has been updated and I hope that addresses any confusion you may have had. Follow its instructions while looking at your QUERY separately from the rest of your formula. Please continue contributing to this community. Commented Jan 2 at 1:21
• Thanks. I've tried adding in the LABEL statement in various places but I can't just find the right place that doesn't cause an error. I'm pretty new to Query / Select and learning on the fly. Are you able to point me in the right direction please. Commented Jan 12 at 10:45
• This is the QUERY in your formula: `QUERY('Base Data'!\$A:\$G, "select sum(E) where B = '"&D\$1&"' and G = '"&\$A2&"'",0)` and LABEL goes inside the `"SELECT..."` before the end: `QUERY('Base Data'!\$A:\$G, "select sum(E) where B = '"&D\$1&"' and G = '"&\$A2&"' LABEL sum(E) ''",0)` Remember to include a space before Label. If you still get an error post the error message and I can help further. Commented Jan 12 at 12:40

# Solution

`=IF(\$B2="weekday", IFNA(QUERY('Base Data'!\$A:\$G, "SELECT sum(E) WHERE B = '"& D\$1& "' AND G = '"& \$A2& "' LABEL sum(E) ''", 0)),)`

Equivalent but line breaks added to assist visually:

```=IF(\$B2="weekday",
IFNA(
QUERY('Base Data'!\$A:\$G,
"SELECT sum(E)
WHERE B = '"& D\$1& "' AND G = '"& \$A2& "'
LABEL sum(E) '' ", 0)),)```

# Explanation

1. The IFNA-wrapped QUERY function in your original formula is the IF function's value_if_true argument:

`=IF(logical_test, IFNA(QUERY), value_if_false)`
2. QUERY follows function follows the syntax:

`=QUERY(data, query_text, [headers])`

Excluding its data argument, `'Base Data'!\$A:\$G`, and headers, `0`, what remains is the query_text:

```=QUERY('Base Data'!\$A:\$G, "SELECT sum(E)
WHERE B = '"& D\$1& "' AND G = '"& \$A2& "'", 0)
```

and your `LABEL sum(E)` would go at the end of it

`"select sum(E) where B = '"& D\$1& "' and G = '"& \$A2&"' LABEL sum(E) '' "`

`=IF(1=2, valu_if_true, )`
`=IFNA(#N/A)`