Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
linoyel
Specialist
Specialist

Trigger to clear previous date selection

Hi,

In my sheet a user can select either dates (from and to) in the Calendar Object, or he can select Date from separate List Box.

I managed to connect the Calendar Object selections to the Date List Box, so when a user pics From and To dates from the Calendar, in Current Selections box it shows: Date ='>=' &_DateFrom & '<=' & _DateTo (the On Select Trigger).

Now, after this, a user for example wants to select a specific date from Date List Box. Current Selections Box updates in a right way, but the Calendar Object remains with previous selections.

I need a trigger which will erase those selections if the user selects date from Date List Box.

Thank you!

1 Solution

Accepted Solutions
jerem1234
Specialist II
Specialist II

Looks like your DateFrom and DateTo are fields? Then you would want to set the trigger in your document properties for your field 'Date'. Using OnSelect, add 2 actions of

Clear Field -> (Field) _DateFrom

Clear Field -> (Field) _DateTo

So when you select the dates in your listbox, it will clear your To and From dates.

Hope this helps!

View solution in original post

16 Replies
maxgro
MVP
MVP

Try with a document trigger

 

Menu --> Settimgs --> Document Properties --> Field Event Triggers --> Choose Date field --> On Select --> Add Actions)

The trigger should be

Action Type:      External

Actions:             Set Variable

Variable:            _DateFrom

Value:                =null()      // =min(Date)

And add the same action for _DateTo

linoyel
Specialist
Specialist
Author

It's not working because the field _DateFrom and _DateTo in the Calendar are already triggered:

DateFrom<Has Action(s)> --> on select --> (Actions)Select in Field --> (Field) Date --> (Search String) ='>=' &_DateFrom & '<=' & _DateTo

Meaning when user selects something in Calendar he actually selects values from Date field.

I need the reverse action - if user selects values in Date field - I want the previous selection in Calendar (if was) to be emptied

jerem1234
Specialist II
Specialist II

Looks like your DateFrom and DateTo are fields? Then you would want to set the trigger in your document properties for your field 'Date'. Using OnSelect, add 2 actions of

Clear Field -> (Field) _DateFrom

Clear Field -> (Field) _DateTo

So when you select the dates in your listbox, it will clear your To and From dates.

Hope this helps!

Anonymous
Not applicable

Linoy Barnea,

Looks like you have a logical loop.

Selection in _DateTo (_DateFrom) triggers selection in Date.  That means, if selection in Date changes _DateTo (_DateFrom), they in turn select Date, which you don't want.

A simple solution is to remove triggers from the _DateTo and_DateFrom fields, and instead add a button "Apply Date Range".  So, selections in _DateTo (_DateFrom) don't do anything until you click the button.  Besides, it helps to avoid selection before both ends of the range are defined.  Just add trigger from jerem1234

Regards,

Michael

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi Linoy,

I often find that when you want to and from dates it is easier and more robust to implement these using variables.  This way the variables are not affected by selections and you can simply apply the range using Set Analysis.

I've uploaded an example of how you can manipulate those date variables using actions on buttons here:

QlikView App: Using Actions To Change Date Variables

Hope that helps,

Steve

Anonymous
Not applicable

Steve, can't disagree with that.  Variables are usually more suitable for this sort of task.

Linoy,

If you don't like simple solutions, see attached.  It uses macro though, and a variable too but in a different way.

Regards,

Michael

linoyel
Specialist
Specialist
Author

Thanks a lot, that worked!!

linoyel
Specialist
Specialist
Author

Hi Michael, what do you mean by saying - add a button "Apply Date Range"?

linoyel
Specialist
Specialist
Author

Hi Steve, thanks for showing an interesting implementation of choosing dates using variables.

I'll probably use it somewhere in the future.

In my case, though, I don't understand how it will help because in my sheet a user can select either date range from Calendar, or Day, Month, Year or Date separately (these are all fields), and what I wanted to do is to connect the selection of separate fields to Calendar object. Well, implementing the "Clear Field" trigger solved my issue.