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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Passing values to variables based on selections

Hi All,

I was wondering if it was possible to pass values to variables based on selections .

For eg. If I select a Year= 2010, the variable vDate should store the value 01/01/2010.

If I select Year= 2010 and Month=7, the variable vDate should store 07/01/2010.

It would be extremely helpful if someone could provide a solution.

Thanks,

Neeraj

5 Replies
Not applicable
Author

You can use a GETFIELDSELECTIONS(your_field) function!!!

For more details...look a help from QV!!!

Not applicable
Author

go to variable overview and make a variable like:

makedate([Year],[Month],[Day])

Which assumes you also have a [Day] field but if not just put 1 instead of day

There could be some issues like if you have more than one year or month selected in which case it isn't going to return anything. I could never figure out how to make that case work but it has something to do with concat I think...

patricio
Contributor III
Contributor III

You can define vDate to be:

=Only(Year)

In this case you have the year in vDate once you select only one Year.

You can also use other options depending what you really need to have in your variable.

Example if you define your variable to be:

=Only(Makedate(Year,1,1) )

you will have the first day of earch year. Example: 2010-01-01 whe you select only 2010.

Not applicable
Author

Hi Erico, Trent,

Thank you very much for helping me out.

I think get field selections function will help me to deal with multiple selections as well.

Thanks,

Neeraj

Not applicable
Author

Hi Patricio,

Thank you very much. A combination of the above 3 solutions should serve my purpose well. Will get back if I face hiccups.

Thanks,

Neeraj