Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
hello,
I have a field which contains the dates of the last 3 months from today's date.
I want to create from this field a personalized list box which contains the following
3 labels:
- the last 30 days (select all the dates of the last month)
- the last 60 days (select all the dates of the last two months)
- the last 90 days ( select all the dates of the last three month°
I used this expression :
=if(CS_LastUpdate >= today()- 30, 'the last 30 days',
if(CS_LastUpdate >= today()- 60, 'the last 60 days',
if (CS_LastUpdate >= today()- 90, 'the last 90 days')))
But it gives me an incorrect result.
for the label "last 30 days" it gives good results but for the last 60 days for example, it selects only the second
last month without taking into account the last month. Same for the label "last 90 days", it select all the dates of
the 3rd last month without taking into account the two months which are before. Any solution please ?
Thanks in advance
Try the below script
T1:
LOAD Date,
if(date(Date,'MMDDYYYY')>=Today()-29,'the last 30 days') as days_30,
if(date(Date,'MMDDYYYY')>=Today()-59,'the last 60 days') as days_60,
if(date(Date,'MMDDYYYY')>=Today()-89,'the last 90 days') as days_90
FROM
[C:\Users\NM\Desktop\Scenarios\19 feb21\New Microsoft Excel Worksheet.xlsx]
(ooxml, embedded labels, table is Sheet1);
T2:
CrossTable(Days,Data,1)
load * Resident T1;
DROP Table T1;
Could you please elaborate more on incorrect result you are observing on using expression mentioned in above comment.
for the label "last 30 days" it gives good results but for the last 60 days for example, it selects only the second
last month without taking into account the last month. Same for the label "last 90 days", it select all the dates of
the 3rd last month without taking into account the two months which are before.
Sometimes before, I have replied with my approach. Please check if this suits your requirement too.
https://community.qlik.com/t5/New-to-QlikView/Date-selections-on-Multiple-Date-fields/m-p/1700535
Try the below script
T1:
LOAD Date,
if(date(Date,'MMDDYYYY')>=Today()-29,'the last 30 days') as days_30,
if(date(Date,'MMDDYYYY')>=Today()-59,'the last 60 days') as days_60,
if(date(Date,'MMDDYYYY')>=Today()-89,'the last 90 days') as days_90
FROM
[C:\Users\NM\Desktop\Scenarios\19 feb21\New Microsoft Excel Worksheet.xlsx]
(ooxml, embedded labels, table is Sheet1);
T2:
CrossTable(Days,Data,1)
load * Resident T1;
DROP Table T1;
Amazing! it works . Thanks a lot 😊