Skill level: Intermediate
Time required: 10 minutes
This article demonstrates how to use queries to fetch cell data in Google Sheets using Quickwork.
Prerequisites
- Create a sample Google Sheet that contains some information about the users.
Note: When executing a query, keep these essential points in mind to prevent errors:
- It is necessary to have data stored in a spreadsheet in plain text format, especially dates. To do this, press CTRL + A and navigate to Format > Number > Plain text.
- Always pass the string and integer values in single quotes 'XYZ' while writing a query. For example, Select * Where A = 'Sam'
- Column headers (titles) must not include spaces. Use underscore '_' to separate two words. For example, Shirt_size instead of Shirt size.
Step-by-step guide
Configuring the trigger
-
Under the Event section, choose the Scheduler by Quickwork app from the drop-down menu in the Apps field present right below the New Trigger button.
- Select the trigger event, New scheduled event, from the drop-down menu in the Triggers field.
- Set the Interval as per your choice based on how many times you want the journey to run.
- Set the date and time of your choice in the Start at field and keep the Custom payload field empty.
Configuring the Google Sheets-Search cell using query action
- Under the Steps section, click on the Simple Action button and choose the Google Sheets app from the drop-down menu present in the Apps field.
- Select the action, Search cell using query, from the drop-down menu in the Actions field.
- Authorize your Google Sheets account by clicking the Link an account button, selecting the Gmail account that contains the above spreadsheet, and allowing the set of permissions.
- A set of input fields will open. In the Spreadsheet field, select the Ecommerce customer list spreadsheet, which we had created earlier, from the drop-down menu.
- In the Sheet name field, select the sheet that contains the data of the spreadsheet. For example, Sheet 1.
- In the Query string field, let's write a query that will help to search for data in the cell(s):
Operation Query Meaning To find complete information of a specific user by name Select * Where A = 'Jon Doe' Select users whose name is Jon Doe and return all the information.
Here, * denotes all columns and A denotes the name of the column header named Age in the spreadsheet.
- Specify this query in the text format in the Query String field:
8. Save the changes done in the journey and click the Start journey button. Check the Output block of the Google Sheets action.Examples of Query String use cases
Operation Query String Meaning To search users by email address Select * Where B = 'jenny@gmail.com' Select users whose email is jenny@gmail.com and return all their information.
Here, * denotes all columns and B denotes the name of the column header named Email in the spreadsheet.
Output
Operation Query String Meaning To search users whose age is equal to 25 years Select * Where C = '25' Get the information of users whose age is equal to 25 years.
Here,* denotes all columns and C denotes the name of the column header named Age in the spreadsheet.
Output
Operation Query String Meaning To search users whose age is greater than 24 years and opts for a shirt of M or XL size Select * Where C > '24' AND ( D = 'M' OR D = 'XL' ) Select users whose age is greater than 24 years and has opted for a shirt of M or XL size.
Here, * denotes all columns, and C and D denote the name of the column headernamed as Age and Shirt_size in the spreadsheet.
Output
Operation Query String Meaning Get all the users and their information Select * Select and show all records
Here, * denotes all columns
Output
Note:For a detailed understanding of the clauses, conditions, syntax, and operators supported in Quickwork queries, click here.
Comments
0 comments
Please sign in to leave a comment.