How to compare to a previous period (on the same row)

Hi,

Pivot table is a great feature.

I try to show the % of difference between 2 periods on the same row.
I know that I can use Custom expression with SumIf and between.
But not sure how to do it.

With the sample Dataset, on the same row, I want to have this result :

| USER_ID → STATE | PRODUCT_ID → CATEGORY | TOTAL for Period 1 | TOTAL for Period 2 | % Period 2 vs Period 1 |

| AK | Doohickey | 2 651,76 | 867,63 | -67.28% |

Thanks for help.

Nicolas

Hi @nico8
Have you looked at this article?
https://www.metabase.com/learn/building-analytics/notebook-editor/time-series-comparisons.html

Time series comparisons will work with full year and if I select the full period between years compared.
But I want to show the sales of january 2020 and see the comparison with january 2019, I need to do this :

Ok, I can work :

But if I need to have dynamic comparison for previous day, previous week, seems complicated.
A function likes CompareTo ( [Date], Interval (day, week, month, quarter, year), [ [Date to compare] ])
And in the filter for period, only january 2020 is selected.

Nicolas

@nico8 Upvote the following two issues by clicking :+1: on the first post of each:
https://github.com/metabase/metabase/issues/11330
https://github.com/metabase/metabase/issues/5606