Qlik Community

Qlik NPrinting Discussions

Discussion Board for collaboration on Qlik NPrinting.

agnes_li
New Contributor II

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?

Tags (2)
1 Solution

Accepted Solutions
geminihzh
Valued Contributor

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

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

8 Replies
jonathanruiz
New Contributor III

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

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
Valued Contributor II

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

You can use Today()-7.

Capture.PNG

geminihzh
Valued Contributor

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

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

agnes_li
New Contributor II

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

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

agnes_li
New Contributor II

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

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

agnes_li
New Contributor II

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

Hi Zhihong, it works! Thanks a lot!

geminihzh
Valued Contributor

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

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

geminihzh
Valued Contributor

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

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

Community Browser