Trends comparing Last 30 days to Last 60 days

I've been trying to use the trends visualization and it works pretty well when the query is grouped by month or day.
But I do have a specific example where I want to compare Last 30 days to the Last 60 days. Is it possible? If so, how can I do that without using group by?

Thank you in advance

1 Like

Hi @gabi
That's currently not possible to do with Trend visualization. It would require windowing:
Sliding windows in MBQL · Issue #9393 · metabase/metabase · GitHub
You can however do something like this:


Where the Custom Column is like this:
case(interval([Timestamp], -30, "day"), "Last 30 days", interval([Timestamp], -60, "day"), "Last 60 days")

2 Likes

I build a view table in my Mysql database to solve this, but i'll try your example, too.

Edit: @flamber Do you also have a tip to create an overlapping line graph's showing values from today to -30 days, compared to -30 days to -60 days?

1 Like

@toink That's currently not possible. You would have to use hours or minutes instead.
https://github.com/metabase/metabase/issues/12457 - upvote by clicking :+1: on the first post

1 Like