Add Field Label to Array Formula Result in Google Sheets

In Query, there is an option (clause) to name or rename field labels (column names). I think no other functions have that cool feature. But it’s easy to add a field label to an array formula result in Google Sheets.

Adding Field Label to a Single Cell Formula Output (Non-Array Formula Output)

To add field labels, you must use the Curly Braces. I think instead of giving you more details, the best way is showing you a screenshot.

Formula # 1:
={“Salary”;B2:B10*C2:C10}
Adding Column Label to a Single Cell Formula Result

Normally to get the salary of the employee “Alex”, you can use the formula B2*C2 in cell D2.

Here I want to add the column name “Salary” to that output. The formula added in cell D1 does that correctly.

See how I have used the Curly Braces. The column name is within double quotes as it’s a string and put a semi-column between the formula and the column name.

Using the semi-colon may not work if you are from any of the EU countries. Check the following tutorial for more info on this – How to Change a Non-Regional Google Sheets Formula.

Finally, the formula is wrapped by the Curly Braces. This is what you want to follow with array formula outputs too.

Adding Field Label to Single Column Array Formula Result in Google Sheets

Several functions in Google Sheets can return a single column output. A few of them are ArrayFormula, Filter, Sort, and Sortn. Here also, you can follow the above same method to add a column name to the first row.

Here are two examples. One with ArrayFormula and another with the function Filter.

How to Add Column Name to a Single Column ArrayFormula Output

I am adding more rows to the data used in the earlier formula example. See that data and the formula first.

Formula # 2:
=ArrayFormula({“Salary”;B2:B*C2:C})
Add Field Label to the First Row of a Single Column ArrayFormula

The formula is almost the same as Formula # 1. The only difference is the inclusion of ArrayFormula and the infinite column ranges.

The formula returns additional values in row # 11, 12, and 13. To omit that simply modify the formula # 2 as below.

=ArrayFormula(if(A1:A<>"",{"Salary";B2:B*C2:C},))

How to Add Field Label/Column Name to Filter Output

Assume you want to extract the name of the employees whose basic salary is 4500. Here you can use the Filter function.

Here I am adding a column name to the filter formula output.

Formula # 3:
={"Name";filter(A1:A,B1:B=5500)}
Get Column Name in Filter Function in Sheets

I have added the column name “Name” to the top row of the Filter formula result.

Finally, I am going to use the above formula to return a four-column output. I mean the Name, Basic, Present Days, and Salary of employees whose basic pay is 4500.

Adding Column Name to Multiple Column Output in Google Sheets

Formula # 4:
={"Name","Basic","Present Days","Salary";filter(A1:D,B1:B=5500)}
Add Field Label to a Multi-Column Array Formula Result

Interestingly, you can use corresponding cell references in the above formulas to add field labels. As an example, you can replace the last formula with the following formula.

={A1:D1;filter(A1:D,B1:B=5500)}

That’s all for now. Hope you have enjoyed the stay!

Find more helpful tips and tutorials at Crawlan.com.

Related posts