Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Experts,
How to find last 5 days depending selection.
For Ex: I have below data.
Tr_Date | Sales |
01-05-2015 | 10 |
02-05-2015 | 23 |
03-05-2015 | 34 |
04-05-2015 | 55 |
05-05-2015 | 12 |
06-05-2015 | 11 |
07-05-2015 | 22 |
08-05-2015 | 33 |
09-05-2015 | 45 |
Filter is Tr_ Date
Straight table: Dim - Tr_Date, Expression - ?
so If I select Tr_Date-6th then I need 2 to 6 sales.
It works for me, see attached. I used set from sunindia with minor adjustments.
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.
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