https://github.com/robiningelbrecht/google-spreadsheets-improved-query
Use column names in Google Spreadsheets QUERY()
https://github.com/robiningelbrecht/google-spreadsheets-improved-query
Last synced: 6 days ago
JSON representation
Use column names in Google Spreadsheets QUERY()
- Host: GitHub
- URL: https://github.com/robiningelbrecht/google-spreadsheets-improved-query
- Owner: robiningelbrecht
- Created: 2024-05-10T07:56:57.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-05-10T08:20:07.000Z (about 2 years ago)
- Last Synced: 2025-01-17T03:47:34.913Z (over 1 year ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Google spreadsheets improved query
Use column names in your Google Spreadsheets QUERY() functions.
This script is based on this [YouTube](https://www.youtube.com/watch?v=clq7WlC2whk) tutorial.
Script ID: `1BZyZAV5h_cgqvMh0oU86PiKC_GK6yMPPk74eDmQjZ2Ijrhm-si3BwUxd`
## Usage
```
=QUERY(A1:H, SELECT("SELECT SUM([amount]) WHERE [amount] > 0 LABEL SUM([amount]) ''", 'A1:Z1), 0)
```
`SELECT` expects 2 parameters:
- Your query
- Range of the column names (should be exactly one row)
### Query placeholders
Each column name (= placeholder) needs to be surrounded with `[ ]` and can be targeted
with the [camelCase](https://en.wikipedia.org/wiki/Camel_case) version of the names in the "header row":
Column name
camelCase field
id
[id]
Purchased On
[purchasedOn]
Amount
[amount]
## Adding the library to your project
The 'SELECT` function is made available as a script library. Follow [these steps](https://developers.google.com/apps-script/guides/libraries#add_a_library_to_your_script_project) to add it to your project.