Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
lorita2021
Contributor II
Contributor II

create a list boxwith calculated values

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 ? 
lorita2021_0-1613662432640.png


Thanks in advance

Labels (1)
1 Solution

Accepted Solutions
manoranjan_d
Specialist
Specialist

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;

 

View solution in original post

5 Replies
gkhetan
Contributor II
Contributor II

Could you please elaborate more on incorrect result you are observing on using expression mentioned in above comment. 

lorita2021
Contributor II
Contributor II
Author

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.

Saravanan_Desingh

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

manoranjan_d
Specialist
Specialist

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;

 

lorita2021
Contributor II
Contributor II
Author

Amazing! it works . Thanks a lot 😊