# Previous Period Comparison

**URL:** <https://community.amazonquick.com/t/previous-period-comparison/13207>\
**Category:** Q&A\
**Tags:** period-over-period, quick-sight\
**Created:** [May 9, 2023, 12:23am UTC](https://community.amazonquick.com/t/previous-period-comparison/13207 "2023-05-09T00:23:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![terryb](https://avatars.discourse-cdn.com/v4/letter/t/cab0a1/32.png) [@terryb](https://community.amazonquick.com/u/terryb)\
**Post date:** [May 9, 2023, 12:23am UTC](https://community.amazonquick.com/t/previous-period-comparison/13207/1 "2023-05-09T00:23:24Z")

</div>

Hi,

I’m new to Quick Sight and having a problem retrieving comparative data for the same month last year.

I’m using 2 calculated fields:

- Same Month LY Date = addDateTime(-1, ‘YYYY’, {This Month Start Date})
- Same Month LY Value = periodOverPeriodLastValue(sum({Sales}), {Same Month LY Date}, YEAR, 1)

… but no value is returned.

What am I missing?

Any help will be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![Max](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/max/32/2288_2.png) [@Max](https://community.amazonquick.com/u/Max)\
**Post date:** [May 9, 2023, 1:48pm UTC](https://community.amazonquick.com/t/previous-period-comparison/13207/2 "2023-05-09T13:48:01Z")

</div>

You don’t need to add the same month LY Date.

You should be able to do just this.

periodOverPeriodLastValue(sum({Sales}), {This Month Start Date}, YEAR, 1)

---

<div class="post-metadata">

**Author:** ![terryb](https://avatars.discourse-cdn.com/v4/letter/t/cab0a1/32.png) [@terryb](https://community.amazonquick.com/u/terryb)\
**Post date:** [May 9, 2023, 11:06pm UTC](https://community.amazonquick.com/t/previous-period-comparison/13207/3 "2023-05-09T23:06:46Z")

</div>

Hi Max,

Thanks for your response.

I made the change you suggested but, unfortunately, got the same result.

---

<div class="post-metadata">

**Author:** ![kaare](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/kaare/32/8618_2.png) [@kaare](https://community.amazonquick.com/u/kaare)\
**Post date:** [May 10, 2023, 6:48am UTC](https://community.amazonquick.com/t/previous-period-comparison/13207/4 "2023-05-10T06:48:50Z")

</div>

Hi terryb,

To improve the communication, and the chance of obtaining an answer which is usable for you, I would suggest that you elaborate a little more on your use case. To be precise,

- What does your dataset look like?
- What fields does your dataset have, and what type do these fields have?
- Provide a minimalistic example of some data that you might have in that dataset.
- I.e. not too many rows, but still enough rows to capture the essence of your case.
- And finally, for that very concrete dateset, explain what kind of output you are looking for? Do this by providing your own manually computed and formatted results. It will enable the community to support you better.

Cheers,  
Kåre

---

<div class="post-metadata">

**Author:** ![terryb](https://avatars.discourse-cdn.com/v4/letter/t/cab0a1/32.png) [@terryb](https://community.amazonquick.com/u/terryb)\
**Post date:** [May 14, 2023, 11:15pm UTC](https://community.amazonquick.com/t/previous-period-comparison/13207/5 "2023-05-14T23:15:32Z")

</div>

Hi Max & Kaare,

Problem solved!

After receiving Kaare’s response, I re-checked my dataset and found and corrected the problem. The periodOverPeriodLastValue function now works as per Max’s response.

Thank you both for your assistance. Much appreciated.
