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: 
Not applicable

Current week/year Default Selection

Hi.

i am looking to set current week as a default selection.

i have created a trigger  (based on object name week) as following

weekyear(today(week))

However this is not working.

attached is a sample file.

Best,

Bradley

1 Solution

Accepted Solutions
Gysbert_Wassenaar

The weekyear function returns an integer value representing a year. For example weekyear( '1996-12-30' ) returns 1997. The today() function can make use of 0,1 or 2 as parameter. Anything else won't do anything. So weekyear(today(week)) won't do what you want. At best it returns the current year.

Depending on what kind of data type week_year has you need either a date, in which case today() should suffice, or you need to construct a string:  year(today()) & '/' & week(today())


talk is cheap, supply exceeds demand

View solution in original post

6 Replies
Gysbert_Wassenaar

The weekyear function returns an integer value representing a year. For example weekyear( '1996-12-30' ) returns 1997. The today() function can make use of 0,1 or 2 as parameter. Anything else won't do anything. So weekyear(today(week)) won't do what you want. At best it returns the current year.

Depending on what kind of data type week_year has you need either a date, in which case today() should suffice, or you need to construct a string:  year(today()) & '/' & week(today())


talk is cheap, supply exceeds demand
Not applicable
Author

Hi Gysbert!

This works great,thanks for the advice.

is it possible to change the value once default selection is on?

Gysbert_Wassenaar

A default selection is just a selection. So you can make new selection if you want. Just click on another value to select that. Pressing the Clear button would also remove it.


talk is cheap, supply exceeds demand
Not applicable
Author

Hi Gysbert!

thanks for all the advise. However, in my case i have the problem that when the action is set on the field, it is impossible to remove the default selection value.

i have attached the qvw to the original message for further clarity.

i suppose there is a parameter setting i have missed?

Best,

Bradley

Not applicable
Author

This Problem is now Solved.

To ensure Default selection and the ability to change the default you need to set a trigger on on the field event with the selection OnSelect (Edit Action) and OnChange.

Thank you for your help once again.

OnChange

=

Week

OnSelect

=

week(today())

Gysbert_Wassenaar

Well, that's because you added it to the field trigger. What happens now is that any time the selection in Week changes the selection is set to the week of today(). So if you choose week 2 the trigger fires and value 17 is selected.

Just remove it from the field trigger and leave the action on the sheet trigger. You can also add the same action to the OnOpen document trigger so the right week is set when you open the document.


talk is cheap, supply exceeds demand