I have a table calculation with a query like below:
count_distinct user_id / total_number_of_users
Both are basically the same, but this needs to be filtered bu users.last_logged_in_at.
So when I add filter with users.last_logged_in_at in past 12 months query should become:
(count_distinct user_id where last_logged_in_date in past 12 months) / total_number_of_users
SQL query is something like:
SELECT
count(DISTINCT users.id) / (SELECT count(DISTINCT users.id) FROM users)
FROM users
WHERE users.logged_in_at BETWEEN date_sub(now(), INTERVAL 12 MONTH) AND now();
Date filter must be dynamic and can be change by users to past x months, so it cannot be hardcoded in the query.
Any suggestion on how to do this without any LookML change?