# YOY calculation got errased

**URL:** <https://community.amazonquick.com/t/yoy-calculation-got-errased/38018>\
**Category:** Q&A\
**Tags:** calculated-field, calculations-editor, calculation, calculations, Business-Intelligence-Engineer, quick-sight\
**Created:** [November 5, 2024, 10:20pm UTC](https://community.amazonquick.com/t/yoy-calculation-got-errased/38018 "2024-11-05T22:20:12Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Xclipse](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/xclipse/32/20455_2.png) [@Xclipse](https://community.amazonquick.com/u/Xclipse)\
**Post date:** [November 6, 2024, 8:01am UTC](https://community.amazonquick.com/t/yoy-calculation-got-errased/38018/2 "2024-11-06T08:01:58Z")

</div>

Hi @Geral

Welcome to the Quick Sight community!

The issue you’re facing, where adding a year filter deletes the calculated YoY (Year-over-Year) field, occurs because of how filtering affects the data context for calculated fields. When you apply a year filter (e.g., selecting only ‘2024’), Quick Sight only retains data for the filtered year. In this case, it removes the ‘2023’ data from the context, meaning that your calculated field no longer has access to both years (‘2023’ and ‘2024’). As a result, the calculation for YoY growth fails since it cannot retrieve values for both years simultaneously.

Your YoY calculation is dependent on data from both 2023 and 2024. When a year filter restricts the data to only a single year (e.g., 2024), the previous year’s value (e.g., 2023) is not available, causing the calculated field to break.

Consider using parameters instead of direct year filtering. Create two parameters for the start year and end year. This way, you have more control over which years are used for the calculation without entirely excluding them from the dataset.

Please refer to the below Quick Sight documentation and community post this might be helpful for you.

> [@YoY% , MoM% and QoQ% calculation for numeric month and year values](https://community.amazonquick.com/t/yoy-mom-and-qoq-calculation-for-numeric-month-and-year-values/8884):
>
> Hello, I am looking to do a YoY%, MoM% and QoQ% difference for the following data which has separate columns for ‘Year’ and ‘Month’ in Integer format. I tried to use the ‘periodOverPeriodDifference’ but it accepts the ‘DateTime’ format in the function parameter. Any inputs on how I could do this or if I can use any other function?

> **[Period over period computation - Amazon QuickSight](https://docs.aws.amazon.com/quicksight/latest/user/period-over-period-function.html)**
>
> The period over period computation compares values from two different time periods. For example, you can create a computation to find out how much sales increased or decreased since the previous time period.

> [@Period Over Period and Other Date Comparison Calculations (YoY, MoM, YTD, Rolling 90 days, etc)](https://community.amazonquick.com/t/period-over-period-and-other-date-comparison-calculations-yoy-mom-ytd-rolling-90-days-etc/564):
>
> Often you may want to create tables and other visuals which display multiple fields that are all ‘filtered’ to different date periods, as well as period-over-period fields. However we can’t use normal filters for this since filters get applied to all fields in the visual. Conceptually in this solution we are building the filters directly into the calculated field itself (using the ifelse logic), so that each field can have a different ‘filtered’ time period. You can then do whatever math you wan…

> **[Using level-aware calculations in Amazon QuickSight - Amazon QuickSight](https://docs.aws.amazon.com/quicksight/latest/user/level-aware-calculations.html)**
>
> Use level-aware calculations in an Amazon QuickSight analysis to insert a window or aggregate function into the order of evaluation.

---

_[View the full topic](https://community.amazonquick.com/t/yoy-calculation-got-errased/38018)._
