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

Date to a variable

Hi,

I have three list box, for year, month and day.

If the user selects the date, I want to pass that to a variable as vPickDate.  And then I want that vPickDate in chart expression.  Like select data when vPickDate is greater than Planned Date.

How do I pass the selections made in day, month, and year to one variable and use that in chart.

I appreciate any help

Thanks

12 Replies
jagan
Partner - Champion III
Partner - Champion III

Use the MakeDate() to generate date based on the Year, Month and Day.

Ex :vPickDate = MakeDate(Max(Year), Max(Month), Max(Day))

Regards,

Jagan.

Not applicable
Author

Great.  Thanks for the reply Jagan

But I want to pass the current selection from the list box to the vPickDate.

How will that work?

Thanks!

jagan
Partner - Champion III
Partner - Champion III

vPickDate = MakeDate(Max(Year), Max(Month), Max(Day))

Here Year, Month and Day are the list boxes.

Suppose if you select

     Year    - 2011

     Month - 2

     Day    - 5

The Max(Year) will fetch 2011 similarly the other will do and by using the MakeDate a date is created.

Regards,

Jagan.

Not applicable
Author

Hi,

The expression Jagan gave you will give you the date of the max values selected for year, month and day, this means that if the user selects more than one value for any of those list boxes, the resulting date will be the max posible date.

If you want to force the user to select just one value for each list box then you can check the option "Always one selected" in the list box properties or you can modify the Jagan's expression to:

MakeDate(only(Year), only(Month), only(Day))

this will give you the date only if one value in each field is selected

Hope this helps

Regards!

Not applicable
Author

Thanks for the reply guys.  Gabriela that was a good point.

But when I execute the script using MakeDate(only(Year), only(Month), only(Day))

I get script line error, any idea why we get that and how to fix that.

jagan
Partner - Champion III
Partner - Champion III

Where are you using this variable in Script or in Expression of a chart.

Regards,
jagan.

Not applicable
Author

I am creating the variable in the script like

LET vPickDate = MakeDate(only(Year), only(Month), only(Day))

When I run the script I get script line error and so the variable is not created

Not applicable
Author

HI,

try adding a ';' at the end of the sentence or use SET instead of LET

Hope this helps

Not applicable
Author

Thanks Gabriela set worked!