Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
priyarane
Specialist
Specialist

Last 5 Days

Hi Experts,

How to find last 5 days depending selection.

For Ex: I have below data.

  

Tr_DateSales
01-05-201510
02-05-201523
03-05-201534
04-05-201555
05-05-201512
06-05-201511
07-05-201522
08-05-201533
09-05-201545

Filter is Tr_ Date

Straight table: Dim - Tr_Date, Expression - ?

so If I select Tr_Date-6th then I need 2 to 6 sales.

13 Replies
Anonymous
Not applicable

It works for me, see attached.  I used set from sunindia‌ with minor adjustments.

petter
Partner - Champion III
Partner - Champion III

I guess it is because the Tr_Date will have the formatted date to whatever the client (or server) is set to as formatting and then try to compare it with the formatted dates in the search string - which will not work I guess ...

Whereas a Date-number should always be safe to compare since it is not subject to formatting settings. I guess the parsing routine for the search string will discover that it is purely date-numbers and then it will use the date-number of Tr_Date instead of it's formatted part.

sunny_talwar

That sounds like a good reason, but my only concern is that what if during the load we have done something like Date(Tr_Date, 'DD-MM-YYYY'), in which case Date() function alone will depart from what has been in the load if the system date is different to DD-MM-YYYY, right?

It seems like a hit and trial method for dates within set analysis, sometimes something work and on other times the same solution won't work. I always struggle to use set analysis on a date field.

Sunny

priyarane
Specialist
Specialist
Author

Hi Sunindia,

Thanks its working.

msolomov‌is aslo said right.