Qlik Community

Ask a Question

Qlik NPrinting Discussions

Discussion Board for collaboration on Qlik NPrinting.

Announcements
Live chat with experts, bring your API Integration questions. June 15th, 10 AM ET. REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
Uri
Contributor III
Contributor III

Latest 2 months data

Hi,

I have a field YearMonth (format: jan. 2021).

Today Im using =YearMonth=max(total YearMonth) to get the latest YearMonth when I open the app.

I want to use a filter in NPrinting to show last 2 months data.

How can I do this?

BR,

Artur

 

Labels (2)
1 Solution

Accepted Solutions
Lech_Miszkiewicz

Hi @Uri 

Have you gone through the links I have sent in my previous post? So the first question is:

  • how is you YearMonth field created in your load script?
    • is it stored in Qlik as text or number 
  • I assume it is actually created as Date(MonthStart(YourDate),'MMM.YYYY') or similar which is still a date!!!! grouped as 1st day of month and with Month.Year format
    • If that is the case then your filter can be created in 2 ways:
      • by creating filter to select current and last month (with Evaluate value option)
        • if your current filter works for current month =YearMonth=max(total YearMonth)
        • then for last month I would do something like this: =YearMonth=AddMonths(max(total YearMonth),-1)
      • by creating range using advanced search

Understanding how is your calendar built as well as if there is association with date field could help as well as I would then use different formulas to select your month year field. I would use this option:

  • current month: =Only({<SomeDateField={'$(=Today())'}>}MonthYear) 
  • last month: =Only({<SomeDateField={'$(=AddMonths(Today(),-1))'}>}MonthYear) 

There is no point talking about filters if we dont know how is your calendar built. It is not really NPrinitng question - it is Qlik Sense question. 

... or maybe you are using autogenerated calendar from Qlik Sense by using "derived fileds" ???

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.

View solution in original post

8 Replies
Andrea_Bertazzo
Support
Support

Hi Artur,

you can add a new value in the same filter and add the previous month.

The formula could be =YearMonth=max(total YearMonth)-1 but this depends on how you defined the YearMonth field

Lech_Miszkiewicz

Here you have short scenarios and things you have to be aware of when working with Advanced Searches and also When working with dates...

https://nprintingadventures.com/2019/06/26/nprinting-filters-part-3-advanced-search/

https://nprintingadventures.com/2019/02/15/the-pitfalls-of-nprinting-filters-part-1-dates-and-duals/

+

landing page: https://nprintingadventures.com

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.
Uri
Contributor III
Contributor III
Author

Hi guys,

YearMonth defined as MonthName(dat) as YearMonth.

I already tried like =YearMonth=max(total YearMonth)-1 and it didn't work.

BR,

Artur

Ruggero_Piccoli
Employee
Employee

Hi,

Could be a problem due to the dual representation of data. Try to force to Text().

Remember also that when you use formulas in filters, you have to select Evaluate value from the dropdown menu.

Best Regards,

Ruggero



Best Regards,
Ruggero
---------------------------------------------
When applicable please mark the appropriate replies as CORRECT. This will help community members and Qlik Employees know which discussions have already been addressed and have a possible known solution. Please mark threads with a LIKE if the provided solution is helpful to the problem, but does not necessarily solve the indicated problem. You can mark multiple threads with LIKEs if you feel additional info is useful to others.
Uri
Contributor III
Contributor III
Author

Hi @Ruggero_Piccoli ,

it doesn't work with text or num either...

BR,

Artur

Lech_Miszkiewicz

Hi @Uri 

Have you gone through the links I have sent in my previous post? So the first question is:

  • how is you YearMonth field created in your load script?
    • is it stored in Qlik as text or number 
  • I assume it is actually created as Date(MonthStart(YourDate),'MMM.YYYY') or similar which is still a date!!!! grouped as 1st day of month and with Month.Year format
    • If that is the case then your filter can be created in 2 ways:
      • by creating filter to select current and last month (with Evaluate value option)
        • if your current filter works for current month =YearMonth=max(total YearMonth)
        • then for last month I would do something like this: =YearMonth=AddMonths(max(total YearMonth),-1)
      • by creating range using advanced search

Understanding how is your calendar built as well as if there is association with date field could help as well as I would then use different formulas to select your month year field. I would use this option:

  • current month: =Only({<SomeDateField={'$(=Today())'}>}MonthYear) 
  • last month: =Only({<SomeDateField={'$(=AddMonths(Today(),-1))'}>}MonthYear) 

There is no point talking about filters if we dont know how is your calendar built. It is not really NPrinitng question - it is Qlik Sense question. 

... or maybe you are using autogenerated calendar from Qlik Sense by using "derived fileds" ???

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.

View solution in original post

Uri
Contributor III
Contributor III
Author

Hi @Lech_Miszkiewicz 

=AddMonths(max(total YearMonth),-1) did the trick.

My YearMonth field looks like this:

MonthName(dat) as YearMonth and stored like (dec. 2020). I will go through your links since I'm still not getting why text() didn't work... I really appreciate your help guys.

BR,

Artur

 

Lech_Miszkiewicz

Text did not work because your YearMonth field is not text field!!! 

https://help.qlik.com/en-US/qlikview/April2020/Subsystems/Client/Content/QV_QlikView/Scripting/DateA...

You always need to know what data type you are working with...  Since it is created by using monthname function it is actually dual field which contains numerical representation and text sumbol of it. For all dual values NPrinting is requiring numerical filter which is documented here:

https://help.qlik.com/en-US/nprinting/February2021/Content/NPrinting/ReportsDevelopment/Static-dynam...

I also mention all this in one of my blog topics "Pitfalls of NPrinitng filters dates and duals...."

 

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.