Hello, how can I use the date range filter for SQL-native questions?
Unfortunately, when I add a date range filter to the dashboard only simple questions show a dropdown with the list of date columns.
I've tried to add WHERE clause with date column into sql query but it didn't help
with cte as (select leads.user_id, leads.orders, date_trunc('day', leads.дата_занесения) as lead_date_added, leads.status, orders.date_added, orders.date_added::date - leads.дата_занесения::date as diff
from leads
left join orders on leads.orders = orders.id)
select
lead_date_added::date,
sum(case when status = 'Order' or status = 'Follow up' or status = 'Dropped' or status = 'Qualification' then 1 else 0 end) as all_valids,
sum(case when diff = 0 then 1 else 0 end) as same_day_orders,
sum(case when diff = 0 then 1 else 0 end)/nullif(sum(case when status = 'Order' or status = 'Follow up' or status = 'Dropped' or status = 'Qualification' then 1 else 0 end),0)::float as same_day_conversion
from cte
where lead_date_added::date >= '2021-10-19'
group by 1
order by 1 desc