postgresql – How can I filter on result of functions like min, max, sum?

In the below query:

SELECT user_id, (max(ts) -  min(ts)) as tsdiff
               FROM analytics 
               GROUP BY user_id

How can I filter on on tsdiff which I assume is a interval? For example I’d like to filter for all records where tsdiff is larger than 1d (one day).

Even if I were to use a subquery, I’d face the same issue again.