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

Announcements
Independent validation for trusted, AI-ready data integration. See why IDC named Qlik a Leader: Read the Excerpt!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Setting a listbox's value to a variable.

Hi guys,

The question is probably a trivial one, I'm essentially looking for a good way to have a dynamic date as a bookmark.

Based on some reading I've done, I'm trying to set the value of the date to a variable that calculates the previous working day. However, I"m unsure of how to assign the value of the date list to the value of the variable itself. I'm hoping that it's possible for the user to click on the list annd press the '=' button and somehow access the variable. I've only started using the application this week so I'm still very ignorant when it comes to Qlikview in general.

I'd be grateful if someone could point me in the right direction.

Many thanks.

14 Replies
Not applicable
Author

Thanks Stefan, here's a quick sample file containing a single list.

If you'd be able to take quick look and get the expression working in the list it'd be much appreciated.

swuehl
MVP
MVP

First of all, I need to correct the above expressions:

You need to use FirstWorkDate() function, not LastWorkDate().

I inputted LastWorkDate(today(),2) in a text box and got Oct-10 back, the correct result, and I haven't noticed that I am using a qvw I opened two days ago. today() will return the date when the qvw has been opened (check the different timer argument settings in the Help, if needed).

Then, if you select values in a field, and then perform a search, I think it will search only in the selected, i.e. possible range of values by default.

When I have opened your sample, I' ve seen that you selected 13 in Day field. So a simple search expression will not work, because it will only see one possible value. You'll need to clear the selection first or use

=only({1}Day)=day(FirstWorkDate(today(),2))

Then 10 will show up when typing this expression and will be selected after submitting the search. The only({1} Day) will expand the search to all Day values, not only to the selected ones.

Hope this helps,

Stefan

Not applicable
Author

Thanks Stefan, that seemed to work perfectly. I had no idea that selecting a value initially would make a difference with the expression. The pointers and help were immensely beneficial

swuehl
MVP
MVP

Unfortunately the search capabilities are one of the least documented areas in QV.

When I said, that search will be limited to the current selection, I was talking about this search format:

=FIELDNAME=SOMEEXPRESSION

For example, is you select 13 and want to search 2, you need to write

=only({1}Day)=2

But for searching literals, it's easier to just put in 2 in the search box, and this method will find also the values that are not possible in your current selection. Kind of confusing sometimes...

Not applicable
Author

Hi Stefan,

I could use some help on this too! My company is addicted to using "Year-Week" (e.g. 2013-12, 2014-01) as a time period, even though it's text and is a pain to sort.

I created a numerical version using

(Year(ActivityDate)&if(Num(Week(ActivityDate))<=9,'0'&Num(Week(ActivityDate)),Num(Week(ActivityDate)))) As KYW

But, when I go to the listbox, and enter in the search box '=KYW=MAX(KYW)', it returns all weeks, not the last one.

Any suggestions?