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: 
nicalbert
Partner - Contributor III
Partner - Contributor III

Using a button to create a selection

Hi everyone,

I there a way to select dates using a button? I need to add a button that dynamically selects the last 7 days based on the current date.

I tried the following, without any luck:

  • Created a button with "Select in field" as Action
  • Identified the date field (in this case ItemCreatedDate)
  • Used the following search string:  ='>=' & Date(Today()-7) & '<=' & Date(Today())
    • Just tried it... I'm not sure about that one!

Does the format of ItemCreatedDate can influence the result? In this case, the format is "YYYY-MM-DD hh:mm:ss".

Can somebody help me on that one?

Nic

1 Solution

Accepted Solutions
MarcoWedel

When changing the date field name, the search string has to be changed accordingly:

So instead of

QlikCommunity_Thread_287710_Pic3.JPG

you should use a search string like

QlikCommunity_Thread_287710_Pic4.JPG

hope this helps

regards

Marco

View solution in original post

11 Replies
YoussefBelloum
Champion
Champion

Hi Nicolas,

Yes it may not work because of the format..

today() is a date and Date(today()) is a date also

your field ItemCreatedDate is a TIMESTAMP, you should interpret this field and format it as a date before, you can create a derived field in the script like this:

Date(Date#(ItemCreatedDate , 'the format you have on the DateFormat variable ')) as new_field_name


! on the button, when you identiy the Date field, make you to not put = sign !

Anil_Babu_Samineni

Perhaps this? Or please post application to test, If dates are real date format then this should work

='>=' & Date(Max(ItemCreatedDate-7), 'YYYY-MM-DD') & '<=' & Date(Today(), 'YYYY-MM-DD')

Please add me Anil_Babu_Samineni to interact faster when reply back. Speak low think High.

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
shiveshsingh
Master
Master

You need to use interpreter to change the format of your Item CreatedDate

May be this..

Date((ItemCreatedDate-7),'YYYY-MM-DD')

kjhertz
Partner - Creator
Partner - Creator

Yes I beleive the format influence the result.. As a test you can try the very same search string in the search box for a List Box object containing the field you wish to search.

Actually you can (and perhaps should?) remove the time part from your ItemCreatedDate if only the date part is relevant.

Else try the following script in an empty app to examine some options for creating a timestamp for your button:

Load

date(Today()-7) as Today,

timestamp(Now()-7) as Now,

timestamp(Date(Today()-7) & ' 00:00:00') as Timestamp,

Date(Today()-7) & ' 00:00:00' as Text

AutoGenerate 1

MarcoWedel

Hi,

one solution could be to use the expression search syntax, thus avoiding date format issues:

QlikCommunity_Thread_287710_Pic1.JPG

QlikCommunity_Thread_287710_Pic2.JPG

='=Date>Today()-7 and Date<=Today()'

see also:

The Search String

The Expression Search

hope this helps

regards

Marco

nicalbert
Partner - Contributor III
Partner - Contributor III
Author

HI Marco,


the example you have provided is exactly what I need to to! But for some reason, it does not work with my actual data.

MarcoWedel

Can you please post a sample of your data to test with?

thanks

regards

Marco

nicalbert
Partner - Contributor III
Partner - Contributor III
Author

There you go!

Thanks again for your help.

Nicolas

MarcoWedel

When changing the date field name, the search string has to be changed accordingly:

So instead of

QlikCommunity_Thread_287710_Pic3.JPG

you should use a search string like

QlikCommunity_Thread_287710_Pic4.JPG

hope this helps

regards

Marco