Using Date Parameters in a GA4 BigQuery query
This article is for Analytics Canvas users who are accessing GA4 data through the BigQuery export.
What are Data Parameters?
A parameter is a variable or a value in a query that can be assigned. A Date Parameter is a date value that can be assigned before running a query. For example, when using a visual date control in a tool like Analytics Canvas, Data Studio, PowerBI, or Tableau, the date parameters control the start and end dates of the query.
Why do you need date parameters with the GA4 BigQuery export tables?
How to use Data Parameters to Create GA4 Report Tables
Examples below are for Analytics Canvas Online users. Desktop / On-prem users should replace @ac_start_date and @ac_end_date with:
'{DateToText(DateOnly($AC_StartDate), "yyyyMMdd")}' and '{DateToText(DateOnly($AC_EndDate), "yyyyMMdd")}'
To add date parameters, you need to include the start and end date in the query, by including the following:
_table_suffix between @ac_start_date and @ac_end_date
FROM`YourProject.analytics_YourProfileID.events_*`
SELECT PARSE_DATE('%Y%m%d',`event_date`) as `date`, geo.country, count(1) as sessions
FROM `YourProject.analytics_YourProfileID.events_*`
WHERE `event_name`='session_start' and _table_suffix between @ac_start_date and @ac_end_date
GROUP BY 1,2
How to use Date Parameters in a GA4 BigQuery SQL Query
Of course these parameters only work in Analytics Canvas. To run this query in the BigQuery SQL editor just put in actual dates:
SELECT PARSE_DATE('%Y%m%d',`event_date`) as `date`, geo.country, count(1) as sessions
FROM `YourProject.analytics_YourProfileID.events_*`
WHERE `event_name`='session_start' and _table_suffix between 'YYYYMMDD' and 'YYYYMMDD'
GROUP BY 1,2
How to use Date Parameters in an Analytics Canvas GA4 BigQuery SQL Query
Within Analytics Canvas, use the BigQuery SQL Import block and add your SQL accordingly. You can then control the date range using the visual date selectors for each import.
Start by adding a BigQuery SQL block to the Canvas.

If you haven't already connected your BigQuery account, follow the instructions here.
Next, add your SQL using the date parameters described above.

Since the query includes date parameters, the option to perform an incremental load is available:

Pressing Submit will store the settings and run the query. Each time the table is refreshed, either through an automation run or through refreshing the Canvas manually, an incremental load will be performed that overlaps the refresh period defined in the last step.
If you need further assistance with querying your GA4 data in BigQuery, contact us at support@analyticscanvas.com