Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
edemerdjieva
Partner - Creator
Partner - Creator

Set variable to a default value

Hi guys,

I have a calendar object and use a variable (vDateSelected) to assign values to that object.

I would like to create a button which resets the value of the calendar to a default value. This means changing the current value of vDateSelected at the click of the reset button.


For this I create a button with "Define variable" action where "Variable" = vDateSelected and "Value" = "=Min({[CurrentMonth]} [Date])". The problem is that the value expression is not interpreted and I have "-" as a result.

What would be the solution of this case? Any help is appreciated .

3 Replies
rubenmarin

Hi Elina, what is 'CurrentMonth'? a variable with month number?

In example it can be something like:

=Min({<MonthNumField={$(CurrentMonth)}>} [Date])


It will filter a field with months in numbers called MonthNumField, where the month number is equal to the variable CurrentMonth, form that month thakes the min date

edemerdjieva
Partner - Creator
Partner - Creator
Author

Hi Ruben,

'CurrentMonth' is one of the values in the "Time" dimension that I use (defined in the load script).

I made another test: I assigned the expression "=Min({<MonthNumField={$(CurrentMonth)}>} [Date])" to a variable in the script and then modified the button action as follows:


"Variable" = vDateSelected

"Value" = vNewDate


But the result is: calendar object is now empty. I have the impression that the expression in vNewDate is not interpreted. On the contrary, if I assign a fixed value to the variable vNewDate then it works (date changes in the calendar object after button click).


Why QlikView does not interpret the expression?


marcus_sommer

Try it with:

"=Date(Min({<MonthNumField={$(CurrentMonth)}>} [Date]))"

because functions like min/max return not a string-interpretation of a date else just the pure number like 43119 for 2018/01/19.

- Marcus