# Rolling days comparison

**URL:** <https://community.amazonquick.com/t/rolling-days-comparison/50022>\
**Category:** Q&A\
**Tags:** kpi, visuals, Business-Intelligence-Engineer, quick-sight\
**Created:** [October 9, 2025, 8:38am UTC](https://community.amazonquick.com/t/rolling-days-comparison/50022 "2025-10-09T08:38:38Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![InbalK](https://avatars.discourse-cdn.com/v4/letter/i/bbce88/32.png) [@InbalK](https://community.amazonquick.com/u/InbalK)\
**Post date:** [October 9, 2025, 8:38am UTC](https://community.amazonquick.com/t/rolling-days-comparison/50022/1 "2025-10-09T08:38:38Z")

</div>

Hello,

I use this KPI visual:

 ![image](https://d1wl4jav5dp96l.cloudfront.net/original/3X/2/4/24ebb2748317d15e29610e3b744aa4734d121345.png)

I want to compare between current 7 days to the previous 7 days (not calendar weeks)

How should I do that?

Thanks

---

<div class="post-metadata">

**Author:** ![andrepgn](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/andrepgn/32/25909_2.png) [@andrepgn](https://community.amazonquick.com/u/andrepgn)\
**Post date:** [October 9, 2025, 10:34am UTC](https://community.amazonquick.com/t/rolling-days-comparison/50022/2 "2025-10-09T10:34:57Z")

</div>

Hi @InbalK ,  
you cannot obtain it directly from the KPI, but we can create a workaround.

Given that we always need the comparison from TODAY, we can create a calculated field which provide us how many weeks from today we are:

```auto
// Given that the date field is called "date"

WeekDiffFromNow = dateDiff( truncDate('DD', date), truncDate('DD', now() ), "WK")

```

You will have something like this in as result:

 ![image](https://d1wl4jav5dp96l.cloudfront.net/original/3X/5/b/5bc80dccd4686c0259ce2546b9d89b765423f254.png)

Now we can take advantage of that calculated number to aggregate our data to single days of week creating another calculated field:

```auto
DaysAggr = addDateTime(-WeekDiffFromNow*7, "DD", truncDate("DD", now()))

```

 ![image](https://d1wl4jav5dp96l.cloudfront.net/original/3X/6/1/6151c328ce5ab4d5b9e0c15b181cf01a212bcf6f.png)

We have aggregated the data in a single day which is distant from today in multiples of 7, so if we now create the KPI visual, you should obtain what you wanted in the beginning, selecting `DaysAggr` as _Trend Group_, instead of the initial `date` field.

These are the two visual in comparison. The first one is using the original `date` as trend group, and if you select **Week** as aggregation, it automatically calculates the diff between entire weeks.  
The second one we use our calculated field `DaysAggr` instead, but just be sure to select **DAY** as aggregation instead of Week!

 ![image](https://d1wl4jav5dp96l.cloudfront.net/original/3X/7/b/7b7a0ea9713eb2c8801e9ce7d042487a8728f9f8.png)

Hope this can be a workaround that fits for you,  
have a nice day!

Andrea

---

<div class="post-metadata">

**Author:** ![InbalK](https://avatars.discourse-cdn.com/v4/letter/i/bbce88/32.png) [@InbalK](https://community.amazonquick.com/u/InbalK)\
**Post date:** [October 9, 2025, 10:52am UTC](https://community.amazonquick.com/t/rolling-days-comparison/50022/3 "2025-10-09T10:52:57Z")

</div>

Thanks!! It works!  
I don’t want to include today, the 7 days should be from yesterday  
What should I do?

---

<div class="post-metadata">

**Author:** ![andrepgn](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/andrepgn/32/25909_2.png) [@andrepgn](https://community.amazonquick.com/u/andrepgn)\
**Post date:** [October 9, 2025, 12:45pm UTC](https://community.amazonquick.com/t/rolling-days-comparison/50022/4 "2025-10-09T12:45:01Z")

</div>

If you want to only exclude today, you can add a filter like this on your original `date` field on the KPI visual.

 ![image](https://d1wl4jav5dp96l.cloudfront.net/original/3X/e/c/eca6b30f592fcb12ddaac8c674ae180e264534a6.png)

Instead, if you want to start counting the days from yesterday, we need to change the formulas in this way:

```auto
WeekDiffFromYesterday = dateDiff(
    truncDate('DD', date),
    truncDate('DD', addDateTime(-1, "DD", now() )),
    "WK")

```

Then

```auto
DaysAggr = addDateTime(-WeekDiffFromYesterday*7, "DD", truncDate("DD", addDateTime(-1, "DD", now())))

```

And still need to use the filter in the KPI graph as shown above!

This should work

Andrea

---

<div class="post-metadata">

**Author:** ![InbalK](https://avatars.discourse-cdn.com/v4/letter/i/bbce88/32.png) [@InbalK](https://community.amazonquick.com/u/InbalK)\
**Post date:** [October 9, 2025, 1:53pm UTC](https://community.amazonquick.com/t/rolling-days-comparison/50022/5 "2025-10-09T13:53:07Z")

</div>

Thank you! Very helpful 🙂  
Now I try to do the same for an insight visual:

 ![image](https://d1wl4jav5dp96l.cloudfront.net/original/3X/b/9/b90ced46c855e76821610aead9f717934c60d07b.png)

How should I fix this error?  
thank you

---

<div class="post-metadata">

**Author:** ![andrepgn](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/andrepgn/32/25909_2.png) [@andrepgn](https://community.amazonquick.com/u/andrepgn)\
**Post date:** [October 9, 2025, 4:27pm UTC](https://community.amazonquick.com/t/rolling-days-comparison/50022/6 "2025-10-09T16:27:00Z")

</div>

The error seems to indicate that you are comparison two periods and for at least one of this you don’t have data, or you have used a field in the period over period that you haven’t selected in the specific visual.

Have a check on this part 🙂

Andrea

---

<div class="post-metadata">

**Author:** ![InbalK](https://avatars.discourse-cdn.com/v4/letter/i/bbce88/32.png) [@InbalK](https://community.amazonquick.com/u/InbalK)\
**Post date:** [October 15, 2025, 9:57am UTC](https://community.amazonquick.com/t/rolling-days-comparison/50022/8 "2025-10-15T09:57:54Z")

</div>

Thanks, I try to do the same for 30 days and 90 days:  
MonthDiffFromNow=dateDiff( truncDate(‘DD’, date), truncDate(‘DD’, now() ), “MM”) 30DaysAggr=addDateTime(-{MonthDiffFromNow}\*30, “DD”, truncDate(“DD”, now()))

It doesn’t work well, it is calculates by calendar month and not by days

 ![image](https://d1wl4jav5dp96l.cloudfront.net/original/3X/a/9/a98ea65708c6737232f97b66052b000f3e63561c.png)

What is the problem and how should i fix this?  
Thanks  
@andrepgn

---

<div class="post-metadata">

**Author:** ![WLS-Luis](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/wls-luis/32/36723_2.png) [@WLS-Luis](https://community.amazonquick.com/u/WLS-Luis)\
**Post date:** [November 3, 2025, 4:29pm UTC](https://community.amazonquick.com/t/rolling-days-comparison/50022/9 "2025-11-03T16:29:42Z")

</div>

Hi @InbalK,

Hope everything is well! Just checking in since this thread hasn’t received a response in a while. Were you able to find a workaround yourself in the meantime or are you still facing persistent issues? If we do not hear back within the next 3 business days, I’ll go ahead and close out this topic.

Thank you!

---

<div class="post-metadata">

**Author:** ![InbalK](https://avatars.discourse-cdn.com/v4/letter/i/bbce88/32.png) [@InbalK](https://community.amazonquick.com/u/InbalK)\
**Post date:** [November 4, 2025, 1:31pm UTC](https://community.amazonquick.com/t/rolling-days-comparison/50022/10 "2025-11-04T13:31:27Z")

</div>

All good now, thanks!

---

<div class="post-metadata">

**Author:** ![WLS-Luis](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/wls-luis/32/36723_2.png) [@WLS-Luis](https://community.amazonquick.com/u/WLS-Luis)\
**Post date:** [November 5, 2025, 2:58pm UTC](https://community.amazonquick.com/t/rolling-days-comparison/50022/11 "2025-11-05T14:58:48Z")

</div>


