Trouble with date fitlers

Hello!

I’m looking to add the daterange filter to my query manually, wondering what I am doing wrong?

select 
    date_trunc("week", CAST(o.PROCESSED_AT AS timestamp)) AS PROCESSED_AT,
    count(distinct o.order_number) as orders

from orders o
where o.PROCESSED_AT = {{daterange}}
    group by 1
    order by 1 desc

Thanks!

also wondering, is there a way to add a filter for aggregation? if i want to filter to daily, monthly etc?

Thanks!

Hi @rjn2, check this page in the documentation https://www.metabase.com/learn/building-analytics/sql-templates/field-filters.html, you need to change the syntax. BTW: that query is easily achievable with the GUI builder

1 Like

@rjn2 It’s currently not possible to change grouping easily. Depending on which type of question you’re using, there’s issues and requests open for that - upvote by clicking :+1: on the first post of each issue:
https://github.com/metabase/metabase/issues/9875
https://github.com/metabase/metabase/issues/6583

1 Like

i simplified it for the example :smile: - but thanks for the link!