Hello
I know I can create a computation where I get users who performed action in the last N days and then filter the number of actions.
However, I want to get the number of users who performed the action N times in the rolling N days.
Is it possible to achieve? I attached the SQL that is achieving what I want to achieve in Amplitude.
SELECT date, COUNT(DISTINCT user_id) FROM (
SELECT
user_id,
date,
SUM(score) OVER (
PARTITION BY user_id
ORDER BY date
ROWS BETWEEN 6 PRECEDING AND CURRENT ROW
) AS rolling_7_day_sum
FROM table_name
)
WHERE rolling_7_day_sum > 25
The sql assumes that there is a row for every day for each user