Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
xaelm
Contributor II
Contributor II

Using a dynamic variable to make/filter a selection (date field)

I'm having trouble using a dynamic variable to filter a selection on a date field.

For example, this works:

xaelm_0-1705592770398.png

While this does not:

xaelm_1-1705593047185.png

 

The variable vRollingThreeMonths has a definition of: 

 

= '>=' & Date(Today()-90) & '<=' & Date(Today())

 

 which (today) evaluates to: 

 

>=10/20/2023<=1/18/2024

 

Why is this not working? I've also tried wrapping the variable in single quotes, brackets, starting with '=Date', etc. and still have not been able to figure this out.

 

Ultimately I would like to filter the sheet by a certain date range by default, while also still being able to use the date picker extension. To do this, I was going to: filter date field by desired range>create a bookmark using this selection>set it as the default bookmark.

 

Any help would be greatly appreciated!

Labels (5)
1 Solution

Accepted Solutions
RafaelBarrios
Partner - Specialist
Partner - Specialist

upsss

sorry, now i can test !!!

the only way a managed to get to works is as follows

=Date>='2023-12-30' and Date<='2024-01-02'
by using variables
=Date>='$(aMinDate)' and Date<='$(aMaxDate)'

RafaelBarrios_6-1705613892698.png

 

having

RafaelBarrios_1-1705613158587.png

 

or

RafaelBarrios_3-1705613714399.png

 

having 

RafaelBarrios_4-1705613810579.png

 

be aware on the equal sign on dates variables and not in DateEval2 variable

 

May I ask what are you trying to achieve? End users generally do not have access to variables definitions and dont use them for searching in filter objects.

 

hope this one helps.

Best,

help users find answers! Don't forget to mark a solution that worked for you & to smash the like button! 

 

 

 

View solution in original post

6 Replies
RafaelBarrios
Partner - Specialist
Partner - Specialist

Hi @xaelm 

you are misssing to specify the field you are looking at

here an example

vGetLogRecord = 2023-12-27

Filter field name: Date

RafaelBarrios_1-1705597319594.png

 

now using:

=Date='$(vGetLogRecord)'

RafaelBarrios_2-1705597358058.png

and

=Month=Monthname('$(vGetLogRecord)')

RafaelBarrios_3-1705597390166.png

 

Here a PDF you can download with more search options

https://www.linkedin.com/posts/rafaelbarriosbelisario_qlik-cheatsheet-activity-7054920286869045249-q...

 

Hope this helps,

Best

 

xaelm
Contributor II
Contributor II
Author

@RafaelBarrios Thanks for replying!

I tried specifying the field in the search expression, but it still isn't working as expected:

xaelm_0-1705602008993.png

 I also tried this with no luck:

 

=Date='$(vRollingThreeMonths)'

 

I believe the issue lies somewhere in the variable expansion and/or declaration because when I filter using static values (i.e. the value that the variable evaluates to) it works as intended:

xaelm_1-1705602476085.png

Any thoughts?

RafaelBarrios
Partner - Specialist
Partner - Specialist

i see,

thats not going to work

this is what its doing

=Date='$(vRollingThreeMonths)'
=Date='>=10/20/2023<=1/18/2024'

look at the single quotes

 

Try This:

 

=Date={">=10/20/2023<=1/18/2024"}
=Date={"$(vRollingThreeMonths)"}

 

 

i can not test, so this can have some syntax error.

help users find answers! Don't forget to mark a solution that worked for you & to smash the like button! 🤗

xaelm
Contributor II
Contributor II
Author

Still no luck but I appreciate all your help thus far! Maybe I need to think of another way to get the functionality I need...

RafaelBarrios
Partner - Specialist
Partner - Specialist

upsss

sorry, now i can test !!!

the only way a managed to get to works is as follows

=Date>='2023-12-30' and Date<='2024-01-02'
by using variables
=Date>='$(aMinDate)' and Date<='$(aMaxDate)'

RafaelBarrios_6-1705613892698.png

 

having

RafaelBarrios_1-1705613158587.png

 

or

RafaelBarrios_3-1705613714399.png

 

having 

RafaelBarrios_4-1705613810579.png

 

be aware on the equal sign on dates variables and not in DateEval2 variable

 

May I ask what are you trying to achieve? End users generally do not have access to variables definitions and dont use them for searching in filter objects.

 

hope this one helps.

Best,

help users find answers! Don't forget to mark a solution that worked for you & to smash the like button! 

 

 

 

xaelm
Contributor II
Contributor II
Author

Rafael,

Thanks for all your assistance, the solution you provided worked! The reason I wanted this functionality is so that the data in the dashboard dynamically filters to display just the last three months by default, but I also wanted users to be able to go back further if needed. I'm still pretty new to Qlik Sense so it might be a weird way of doing it.

How would you achieve that functionality?

Thanks again!