Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

roland74
New Contributor III

How to trigger clear all fields from one table

Hi all,

I have created some calendar buttons in QlikView for Today, Yesterday, Current Week/Month and Previous Week/Month.

These buttons contain a lot of actions, first I use 'Clear Field' for all calendar fields and after that I use 'Select in Field' actions to set the correct date, day, month, week and so on.

I wonder if it is possible to use the Clear Field action for all fields in my Calendar table!?

In a textbox I can use ='['&Concat({1<$Table={'Calendar'}>}distinct $Field,'],[')&']' to show all fieldsfrom the table.

Does anyone have a bright idea?

I cannot use Clear All because I do not want to lose selections on fields other than the calendar.

Thanks a lot!

9 Replies

Re: How to trigger clear all fields from one table

I don't seem to think it is possible using Clear Field action as that seems to be taking only one field at a time. Maybe you can use SubField(Concat({1<$Table={'Calendar'}>}distinct $Field,'|'), '|', 1), SubField(Concat({1<$Table={'Calendar'}>}distinct $Field,'|'), '|', 2) and so on... if you don't want to type each of the field name.

MVP & Luminary
MVP & Luminary

Re: How to trigger clear all fields from one table

Like Sunny said you could apply only one clear (or select) action at one time (unless you would use macros which could run this within a loop). But the question for me is - why do you are not using bookmarks?

- Marcus

Re: How to trigger clear all fields from one table

Marcus‌ is it possible to just put a bookmark on some fields? If not, the bookmark will take the selections at the time of bookmarking as default and as soon as we apply the bookmark those fields will also change, right? Is there a work around?

MVP & Luminary
MVP & Luminary

Re: How to trigger clear all fields from one table

Hi stalwar1‌you could add the bookmark-selections on top of existing selections and the selections within the bookmark could be search-expression like: null() for each of the calendar-fields which would clear them. I have never tried these logic within a bookmark only within actions but I think it's a try worth.

- Marcus

Re: How to trigger clear all fields from one table

I agree. For me it is good opportunity to learn something new. I will see if I can replicate what you just mentioned

Re: How to trigger clear all fields from one table

I gave it a shot, but not sure how it would work. Attaching the sample I worked with

MVP & Luminary
MVP & Luminary

Re: How to trigger clear all fields from one table

Hi Sunny,

many thanks for the sample-file. You are right it's not so easy then I thought it would be. If you simply applied =null() on a field the selection will be cleared without applying the search-expression as selection and therefore there is nothing what you could add to a bookmark.

Therefore I applied a search-expression like: if(1=1, 1) for the fields (I have done this for Date and Month) and created a bookmark with them. Then I exported the bookmark to the desktop, opened it with a editor, searched for the "if(" and changed it to =null() and saved the file. Aterwards I imported the bookmark - and yep - it worked.

The same result should be possible with creating and/or changing a bookmark with the macro API but it will be probably not so understandable like my first approach.

- Marcus

roland74
New Contributor III

Re: How to trigger clear all fields from one table

Thank you both for your input!!

I am not really familiair with bookmarks. Is it possible to have a dynamic bookmark to filter yesterday/today, last/current week, last/current month, etc?

The user wants to keep the selections other than fields from the calendar when using the buttons!

Thanks!

Roland

Highlighted
MVP & Luminary
MVP & Luminary

Re: How to trigger clear all fields from one table

Yes you could have dynamic bookmarks which are using search-expressions. Try for example something like this:

=Date=today()-1 // in Date-field for yesterday

=month(today()) // in Month-field for current month

- Marcus