Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
mattphillip
Creator II
Creator II

Selecting multiple dates using an expression, within an expression

Good afternoon,

I'm hoping someone might be able to assist. We have a sheet within one of our apps where as a sheet action we automatically select a number of corresponding dates to populate a multi-year line chart.

At present we specify the dates within an expression using the following code: 

='(15/01/2019|14/01/2020|12/01/2021|11/01/2022|10/01/2023)'

However, we'd like to make things a little more automated. As such I've tried drafting a more advanced expression. The below script produces the same result (in a text box), however, when it's been tried in the sheet action, it doesn't make any selections.

=(max({1} Date)&'|'&date(max({1} Date-364),'DD/MM/YYYY')&'|'&date(max({1} Date-728),'DD/MM/YYYY')&'|'&date(max({1} Date-1092),'DD/MM/YYYY')&'|'&date(max({1} Date-1456),'DD/MM/YYYY'))

I tried it in a variable, vMultiYear as ='$(vMultiYear)' but still have no luck.

I would be most appreciative it someone could take a look and let me know where I'm going wrong.

Thanks,

Matt

Labels (4)
1 Solution

Accepted Solutions
maxgro
MVP
MVP

Try this (change the date format M/D/YYYY in my expression)

=chr(39) & '('
& max({1} Date) &'|'& min({1} Date) &'|'& date(max({1} Date-364),'M/D/YYYY') &'|'& date(max({1} Date-728),'M/D/YYYY')
& ')' & chr(39)

 

maxgro_0-1673391655811.png

 

 

View solution in original post

2 Replies
maxgro
MVP
MVP

Try this (change the date format M/D/YYYY in my expression)

=chr(39) & '('
& max({1} Date) &'|'& min({1} Date) &'|'& date(max({1} Date-364),'M/D/YYYY') &'|'& date(max({1} Date-728),'M/D/YYYY')
& ')' & chr(39)

 

maxgro_0-1673391655811.png

 

 

mattphillip
Creator II
Creator II
Author

Brilliant thanks Maxgro!!