# Filter by last 45 days (create\_date) based on the month filter

**URL:** <https://community.amazonquick.com/t/filter-by-last-45-days-create-date-based-on-the-month-filter/33997>\
**Category:** Q&A\
**Tags:** analysis, parameters, date, filters, calculations, Business-Intelligence-Engineer, dataset, visual, quick-sight\
**Created:** [August 19, 2024, 10:50pm UTC](https://community.amazonquick.com/t/filter-by-last-45-days-create-date-based-on-the-month-filter/33997 "2024-08-19T22:50:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![praveen.gp](https://avatars.discourse-cdn.com/v4/letter/p/76d3ee/32.png) [@praveen.gp](https://community.amazonquick.com/u/praveen.gp)\
**Post date:** [August 19, 2024, 10:50pm UTC](https://community.amazonquick.com/t/filter-by-last-45-days-create-date-based-on-the-month-filter/33997/1 "2024-08-19T22:50:02Z")

</div>

I have a ‘Create\_Date’ and ‘Month’ fields in my dataset.  
My requirement is to filter the last 45 days based on the month selected from the Month filter.

Let’s say, If I pick **‘Jan-2024’** from the month filter. I need to pick the results from ‘Jan-31-2024’ to last 45 days based on the ‘Create\_Date’ field.

Thank you!

---

<div class="post-metadata">

**Author:** ![michaelpurpura](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@michaelpurpura](https://community.amazonquick.com/u/michaelpurpura)\
**Post date:** [August 19, 2024, 11:06pm UTC](https://community.amazonquick.com/t/filter-by-last-45-days-create-date-based-on-the-month-filter/33997/2 "2024-08-19T23:06:34Z")

</div>

Hi Praveen, what data type is your Month field? Based on your description it appears to be a string instead of a Date, is that the case?

---

<div class="post-metadata">

**Author:** ![praveen.gp](https://avatars.discourse-cdn.com/v4/letter/p/76d3ee/32.png) [@praveen.gp](https://community.amazonquick.com/u/praveen.gp)\
**Post date:** [August 19, 2024, 11:14pm UTC](https://community.amazonquick.com/t/filter-by-last-45-days-create-date-based-on-the-month-filter/33997/3 "2024-08-19T23:14:03Z")

</div>

Hi @michaelpurpura  
Yes, it was a string type initially and I changed it to Date format for my need and I also tried by some calculated fields, but it is not fixing my issue.

I created a month and year filter and set the ‘create\_date’ for last 45 days. Here my issue is it is picking the last 45 days from now(). I want to pick based on the month selected.

---

<div class="post-metadata">

**Author:** ![michaelpurpura](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@michaelpurpura](https://community.amazonquick.com/u/michaelpurpura)\
**Post date:** [August 20, 2024, 7:34pm UTC](https://community.amazonquick.com/t/filter-by-last-45-days-create-date-based-on-the-month-filter/33997/4 "2024-08-20T19:34:56Z")

</div>

Hi Praveen,

You can achieve this without referring to the “Month” field, but using Parameters.

For example, create a parameter named “EndDate”. You can set the default to be the end of the current month.

 ![image](https://d1wl4jav5dp96l.cloudfront.net/original/3X/4/6/468c8950546b1b7f01c87f426b6c9061d17150f9.png)

Add a control for the parameter to your dashboard. You can format this to display as “MMM-YYYY” for example. Under this option, users would need to use the Date Picker control to choose the exact end date.

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

Once you have this established, you can add a filter against the Create\_Date field. Ensure to use “Relative dates”, setting the Period to “Days” and the Range to “Last N days”. Here you can hard-code 45 days, however this can also be controlled by a different parameter.

In the same filter window, set the dates relative to “Date and time from a parameter”, and select the EndDate parameter that was previously created.

 ![image](https://d1wl4jav5dp96l.cloudfront.net/original/3X/2/5/253c3970a1092d3c48db565c4085b1ee564d086c.png)

---

<div class="post-metadata">

**Author:** ![michaelpurpura](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@michaelpurpura](https://community.amazonquick.com/u/michaelpurpura)\
**Post date:** [August 22, 2024, 4:23pm UTC](https://community.amazonquick.com/t/filter-by-last-45-days-create-date-based-on-the-month-filter/33997/5 "2024-08-22T16:23:05Z")

</div>

Hi @praveen.gp, checking in to see if you had any questions on the above note?

---

<div class="post-metadata">

**Author:** ![praveen.gp](https://avatars.discourse-cdn.com/v4/letter/p/76d3ee/32.png) [@praveen.gp](https://community.amazonquick.com/u/praveen.gp)\
**Post date:** [August 23, 2024, 7:06pm UTC](https://community.amazonquick.com/t/filter-by-last-45-days-create-date-based-on-the-month-filter/33997/6 "2024-08-23T19:06:05Z")

</div>

Thanks @michaelpurpura for the explanation.

and I got it through the below calculated field for my requirement.

ifelse({create\_date}\<=MONTH AND {create\_date}\>=addDateTime(-45, ‘DD’, MONTH), 1, 0)
