How obtain % from Pivot or Grouped Table

Hi everyone! I have a table similar to this one

COUNTRY | 2019 | 2020 | 2021
Italy | 1000 | 2000 | 3000
Germany | 1000 | 2000 | 2000

this one is a Table Grouped By Year/Country with Sum of Amount
I would like to obtain a report such like this

COUNTRY | 2019 | 2020 |%| 2021
Italy | 1000 | 2000 | 100%| 3000 | 50%|
and so on ..so add in the report the % of increase from previous year.
Could someone help me in how to get that in Metabase? could be report, query or whatever ...
Thanks in adv for any suggestion
Mrico

Hi @mirco_cervi
Something like this should do it:


Hi @flamber and thanks for your quick response! That's do the job nr. 1 ...many thanks.
Other question related.
Do you think is possible to do it with Pivot table I am trying to do some combo of "Custom Expressio" such as = SumIf(fieldSum, year=2021)/Sumif(fieldSum, year=2020) but it seems not working .. so I am trying other combo!
Any help is appreciated
M

@mirco_cervi
Post "Diagnostic Info" from Admin > Troubleshooting.
And why isn't it working, when you do a Pivot Table? Try using the Sample Database to provide examples.

Ok I have done many test but no Luck :confused:
I have no Database Example (I have deleted...)
I try to explain. Having this pivot TAB A

I would like to create something like this TAB B (dont' care about formatting because I used excel)
image

So I need to add the % between to years.
The issue as explained in previous is that TAB A is a Pivot table and I have no luck in setting Custom Expression

This is TAB A

and this is how is in SQL side ..

Do you have any further idea or direction how to work on it?
Thanks in advance
M

@mirco_cervi You can enable Sample Database via Admin > Databases > look in the bottom, gray link.

It would be rather complicated, if not impossible to do what you want with Pivot Tables currently.
Would likely require something like this: https://github.com/metabase/metabase/issues/2120

My example with a regular table is still valid.

Ok I got the demo! Taking into consideration tab ORDERS I would need to obtain (number are random just for example)
image
Do you think is possible?
The github post refer to % on single row to total sum, here I am comparing 2 columns that are in pivot so i don't have the field name for use in the Custom Expression

@mirco_cervi The example I provided previously will work: How obtain % from Pivot or Grouped Table
Pivot Table has several restrictions, so I don't think you can do what you want there.

OK, got it! thanks

How I did solve?
I did this solution
Select ...
and for each year I did a subSelect as 2020, as 2021, as 2022.
So I have obtained a table
FIELDS | 2020 | 2021 | 2022
avoiding the pivot on metabase. That allow me to do the job.