Using Cell References In Firebase Queries


When retrieving data from Cloud Firestore / Firebase using Two Minute Reports, you might encounter situations where you need to make daily changes to your queries. Whether it’s tweaking the WHERE clause in your fireSQL query or modifying the Structured query, manually editing queries can be time-consuming.
Fortunately, there’s a solution: Using cell references in your Structured query and FireSQL you can dynamically update your queries based on values from the Spreadsheet’s cell value. Here’s how you can do it:


1. Connect to your data source and set up your query as usual. If you haven’t set up your data source yet, follow this guide.

2. Imagine you have a Structured Query like the one below, and you want to dynamically change the filter condition.

Original query:

3. Instead of specifying the filter value in the query, you can place it in any of your Google Sheets and reference that cell in your SQL query.

The cell references should be in the format “+++SHEET_NAME!CELL+++”. This informs Two Minute Reports that there’s a cell reference in your query.

For this example, let’s say your sheet name is “Orders Report” and your cell is “B1”. For this, your cell reference will be in the format “+++Order Report!B1+++”.

Modified query:

Now, when the query runs, Two Minute Reports will get the status from cell “B1” in the “Orders Report” sheet and replace the cell reference in your SQL query.

4. You can do the same in FireSQL as follows:

Original query:

Modified query:

Important Notes:

  1. Be sure to enclose the cell reference with +++ on both sides to signal Two Minute Reports that it’s a dynamic value.
  2. If your sheet name has spaces like “Orders Report”, enclose it in single quotes ().
  3. You can’t specify a range of cells, such as “+++’Orders Report’!A2:A5+++”.

By using this feature, you can dynamically adjust values in your SQL query, fetching specific rows with an “active” status or changing the sorting column from “created_at” to “updated_at”.

We hope this feature and guide are helpful. If you have any more questions or need assistance, don’t hesitate to reach out by creating a support ticket here.

Tags: , , , ,

Was this helpful?