Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Limit date going forward

Hello,

I have a requirement to calculate date range moving forward. Currently I have data for current date and need to limit it to max of 6 months. I am making use of where Datefield<=AddMonths(Today(),6). The problem is currently I have data for Day1 and will keep adding data. Once the maxdate is reached the mindate should move to the next date. I am not sure how to accomplish this. Any help/suggestions is greatly appreciated.

1 Solution

Accepted Solutions
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

   The logic will work because it says that the table or chart should have data from six month back from today.

   If you want to restrict the data at load time you can try something like this.

   Load Field1, Field2, Field3....

 

   From XYZ

    where DateField >= Monthstart(Addmonths(today(),-6));

   Here the expression Monthstart(Addmonths(today(),-6)) will return 1/2/2012. And in where clause you are saying that load the data where the Datefield is Greater than 1/2/2012.

   So even though you are starting the data load from today it will work.

   Hope the idea is clear.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!

View solution in original post

5 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

HI,

    Do you mean you want to look at only the latest 6 months Data? If yes then the logic is as follows.

    your datefield > = monthstart(addmonths(today(),-6))

    Hope this will help.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Anonymous
Not applicable
Author

Thanks Kaushik for getting back.The logic you have mentioned can be used once I reach the 6 month data. Currently I am having Day1 data and if I use this now then it would reload from today's system date moving forward, as I do a daily reload this logic will fail. Hope I am making some sense.

Thanks,

Mak

Anonymous
Not applicable
Author

Any ideas? Anyone?

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

   The logic will work because it says that the table or chart should have data from six month back from today.

   If you want to restrict the data at load time you can try something like this.

   Load Field1, Field2, Field3....

 

   From XYZ

    where DateField >= Monthstart(Addmonths(today(),-6));

   Here the expression Monthstart(Addmonths(today(),-6)) will return 1/2/2012. And in where clause you are saying that load the data where the Datefield is Greater than 1/2/2012.

   So even though you are starting the data load from today it will work.

   Hope the idea is clear.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Anonymous
Not applicable
Author

Kaushik,

I get the logic now, I was seeing it in differently. Thanks for the help.

Regards,

Mak