How can I filter in a count in BigQuery?
In Postgres I was doing something like:
COUNT(*) FILTER (WHERE event_date>('{{ report_date }}'::date-INTERVAL '2 WEEK'))
Though this does not work in BigQuery. What't the best alternative? I use standard SQL.
For BigQuery Standard SQL, you can use COUNTIF and DATE_SUB functions as below
You can test / play with above using below dummy example
The output as one would expect is