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: 
Qlikuser09
Creator II
Creator II

Sort and top 10 dates/ fields in Nprinting HTMl/Pdf

is there a way I could sort and get top 10 Dates / latest dates in Qlik Nprinting (HTML and PDF) format.  

Labels (2)
7 Replies
Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

Yes - There is.

but before I spend time thinking how you would like to present it please invest time to write detailed explanation what you aretrying to achieve. Are you:

  • Trying to filter whole data set only to top 10 dates? - that would be done via filtering (evaluate value or advanced search)
    • that also can be done by setting a flag in load script
  • Trying to get top 10 dates in table/chart-that can be done via dimension limits or set analysis
  • Trying to display 10 text boxes with last/max 10 dates - that can be done with formulas or set analysis

Note - that most of the things need to be done in Qlik Sense before even reaching NPrinting. As I always say: 90-95 % NPrinitng development lays in proper Qlik Sense development.

In any case it is important that you have full knowledge about data type and the way you load dates to your Qlik data model (for example: Date(Floor(yourdate)) as SomeDate ) as that will tell us 2 important informations:

  1. that dates are loaded as integers with dual type of the value (requires filtering using numerical type)
  2. that dates are integers (dont have decimal points - timestamps) in them which is important for filtering too!!

I wrote quite a few posts about dates and filtering and common mistakes people do when not understanding how filtering works. I suggest you have a good read which will help you to get a concept of how to use filters:

After reading above and once you tell us what you are trying to achieve we can give more guidence.

cheers

 

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.
Qlikuser09
Creator II
Creator II
Author

No the Date field is not actually in the date format  , and that's the reason i wasn't able to achieve any thing like this in Nprinting 

=[Datefield]<=$(=max(DateField))-1

so i thought may be sorting and having to display the top 10 would do that

Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

Sitll - not enough information for us to comment. 

If your date is not a date - then what is it? How can you sort something if you dont know the field type. You cant tell if it will sort by text or by numeric value. Depending on type you may use

Regardles - there is always a way to get things right and convert your value to dates using Date#() function in load script. https://help.qlik.com/en-US/qlikview/May2024/Subsystems/Client/Content/QV_QlikView/Scripting/Interpr...

I am guessing here too much so I let you comment on what we are actually dealing with. At the moment we know that: "you want to get max 10 dates which are not dates...."

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.
Qlikuser09
Creator II
Creator II
Author

Now i have the field in the date format as below

Qlikuser09_1-1723035536048.png

I want to filter out the table with the latest 3 days .

 

Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi @Qlikuser09 

  • Option 1 - Sort by date and use dimension limits top 3 + disable others
  • Option 2 - Evaluate value filter as mentioned above in my previous post (note that you will need to provide the same data type as the field (numeric, dual date, integer)
  • Option 3 - Advanced search filter as mentioned above in my previous post
  • Option 4 - create flag in load script and use that flag in nprinting filter.

My prefered option in such case is usually option 2.

cheers 

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.
Qlikuser09
Creator II
Creator II
Author

Qlikuser09_0-1723059207986.png

the above did not give any value in Npriting report , however when i try to fetch the same filter inside qliksense using the formula 

Count({

    <Datefield = {">=$(=Timestamp(Now()-6))"}>}

    ID

) it actually gave me 70 records, is there some thing wrong with my Nprinting formula 

='>=' & Timestamp(Now()-6)

Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi, I have given you all the links and asked to read them thorughly and carefully as explanation and pitfalls are described there.

When using "evaluate value" formula needs to return single value of the field which is why I explained that for max 10 dates you would have 1 filter with 10 values:

  • Max(yourfield,1)
  • Max(yourfield,2
  • Max(yourfield,...)
  • .....
  • Max(yourfield,10)
  • Lech_Miszkiewicz_0-1723096029441.png

     

Study all the previously provided links carefully again also here are documentation links on subject:

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

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

You cannot have ">=" or "<=" in Evaluate Value filter as it is designed to only filter one value at the time returned from formula which is why for your max 10 you need to create 1 filter returning individually all 10 values as on my screenshot and becasue evaluate value requires correct data type to be provided (in case of properly create dates it should be numerical)  you should be ok just with Max() function.

">=" and ",<=" option can be only used with advanced search, but in such case you would need make sure you take into account fact that advanced search filter is a formula working of currentl selection state so other filters may affect results if not handled properly. 

 

The bits from the links I provided in my previous post: 

https://community.qlik.com/t5/Qlik-NPrinting/Extract-the-data-for-Current-Month-and-Previous-Month-b...

 

cheers.

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.