Skip to main content
Announcements
Defect acknowledgement with Nprinting Engine May 2022 SR2, please READ HERE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to set up a filter "Last X days" in NPrinting?

Hi There,

I have a sales report that shows orders. But I only want to see orders with an order date within 7 days, meaning Today-7<Order Date<=Today. How do I set up a NP filter for this? I know I can make a selection in QVW file, make a bookmark for it and use the bookmark as a filter in NP but are there any other options to achieve this?

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi, Agnes,

A better way to do this is to add a new field in your .qvw files like below, that is what I always so if need use date range filter in nprinitng:

LOAD

...

IF  (num([Order Date])>=today()-7, "Last 7 days", "Older than last 7 days") as  OrderDateRang,

...

Because in this way, you can also easier to use the filter in .qvw file, and you can also control to add more "OrderDateRange", like last 30 days or others.

Then you can use the filter OrderDateRange = 'Last 7 days' in Nprinitng.

If you want to directly use the last 7 days in  filter in Nprinting, then you need all the value of the dates of last 7 days:

Date(today()-7, "YYYY-MM-DD")

Date(today()-6, "YYYY-MM-DD")

Date(today()-5, "YYYY-MM-DD")

...

Date(today()-1, "YYYY-MM-DD")


And then pls also notice about the date format, which must be the same as in your dash.


Zhihong

View solution in original post

8 Replies
Anonymous
Not applicable
Author

You can create filters in Nprinting and then associate it with a report, looking for information about dynamic filters, here there is documentation about that,  https://help.qlik.com/en-US/nprinting/17.2/Content/FiltersCycles/StaticDynamicFilters/Static-dynamic...

neelamsaroha157
Specialist II
Specialist II

You can use Today()-7.

Capture.PNG

Anonymous
Not applicable
Author

Hi, Agnes,

A better way to do this is to add a new field in your .qvw files like below, that is what I always so if need use date range filter in nprinitng:

LOAD

...

IF  (num([Order Date])>=today()-7, "Last 7 days", "Older than last 7 days") as  OrderDateRang,

...

Because in this way, you can also easier to use the filter in .qvw file, and you can also control to add more "OrderDateRange", like last 30 days or others.

Then you can use the filter OrderDateRange = 'Last 7 days' in Nprinitng.

If you want to directly use the last 7 days in  filter in Nprinting, then you need all the value of the dates of last 7 days:

Date(today()-7, "YYYY-MM-DD")

Date(today()-6, "YYYY-MM-DD")

Date(today()-5, "YYYY-MM-DD")

...

Date(today()-1, "YYYY-MM-DD")


And then pls also notice about the date format, which must be the same as in your dash.


Zhihong

Anonymous
Not applicable
Author

Thanks, does it mean I need to set up 7 filters for this? =Today()-1, =Today()-2, ....It is not very flexible I guess.

Anonymous
Not applicable
Author

Thanks for your answer Zhihong! I will definitely try it later and let you know how it goes!

Anonymous
Not applicable
Author

Hi Zhihong, it works! Thanks a lot!

Anonymous
Not applicable
Author

Yes, it must work, as I do use it many times.

And one more comment, if you do use the 2nd method, add all the expression values (like the Date(today()-5, "YYYY-MM-DD") ) in 1 filters, sometimes the filter dose not work for some reason, I do not why yet, and then you try to re-create the filter, then it should work finally.

Zhihong

Anonymous
Not applicable
Author

Hope you figure this question out by my answer below, you only need 1 filter, but add multiple value, the dates, that you required

Zhihong