I would like to create a YoY calculation in my pivot table to see the percentage difference between 2022 and 2023. I have created a calculated field “YoY changes” with the formula:

However, because it is looking at the current value and the previous one it is comparing Pink from 2023 to Blue from 2022 (in red in the screenshot) which I don’t want.

Hi Max,
I get the following error “Field NESTED_SUM(“cakes”, “color”) must be aggregated for table calculations.” when trying to save the calculated field with your solution.

Sorry I hadn’t wrapped the cakes in a sum. I now have copied and pasted the exact function, i was able to save the new calculated field. However, I still have the same issue in the pivot table: I have a “YoY Changes” for Blue in the 2022 row (as it’s comparing Blue in 2022 with Pink in 2023). The percentages also now seem off. Please find below what I have now (with real data this time):