There is a table:
| [region] | [country] | [month] | [VAL] | [VAL_PY] |
|---|---|---|---|---|
| EU | Poland | January | x | a |
| EU | Poland | January | x1 | a2 |
| EU | Poland | February | xx | aa |
| EU | France | January | y | b |
| NA | Brazil | February | z | c |
| ... | ... | ... | ... | ... |
there is a need to make another table based on the one above, such as the one below, one row for one country, 12 new columns = 12 months, the value in each country/month is the KPI:
| [region] | [country] | [January] | February] | ... | [December] |
|---|---|---|---|---|---|
| EU | Poland | KPI | KPI | ... | KPI |
| EU | France | KPI | KPI | ... | KPI |
| ... | ... | KPI | KPI | ... | KPI |
The KPI code:
CASE WHEN sum(A."value_py")=0 THEN 0
else round(((sum("value")-sum("value_py"))/sum("value"))*100,1
END
Please help me, I can find the solution where there are duplicates in every country which is not acceptable