Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Usage of variable in a Expression

Hi Guys,

I have a Date(30.06.2009) set as a Variable(vDate) and assigned to a calenderobject. I want to use this variable in the Expression of a chart. if there are other fields like BegDate with 2 input fields =2005-01-01,2009-01-01 and EndDate with 2 input fields as 9999-12-31,2008-12-31

For ex:- If(vDate >=BegDate and vDate <=EndDate, cond1, cond2)

it must select the fields BegDate=2009-0-01 and EndDate=9999-12-31 and give the cond1 correctly

but that doesnot happen. Any ideas?

Regards

Sravan

1 Solution

Accepted Solutions
Not applicable
Author

I dont understand either but the date formats you show in your post are inconsistent (dots and hyphens). Yo may need to use the date# function to ensure correct interpretation as dates.

Regards,

Gordon

View solution in original post

12 Replies
stephencredmond
Luminary Alumni
Luminary Alumni

Hi,

I can't understand exactly what you are trying to do.

Could you post a QVW and expand on your description?

Regards,

Stephen

Not applicable
Author

I am attaching the example..

May be some one can help me.

Thanks[View:http://community.qlik.com/cfs-file.ashx/__key/CommunityServer.Components.UserFiles/00.00.00.49.52/Test.qvw]

Not applicable
Author

I dont understand either but the date formats you show in your post are inconsistent (dots and hyphens). Yo may need to use the date# function to ensure correct interpretation as dates.

Regards,

Gordon

biester
Specialist
Specialist

Hi Sravan,

first:

you have to use date# as Gordon says. Then second, you have to use $(=VDate), third you have to enclose this in apostrophes like this:
date#('$(=VDate)','DD.MM.YYYY')
Forth: you have to use a aggregation, like = sum(if (.....
And fifth: it will NEVER work when the name of the variable is VDate and you use vDate in your expression.

Rgds,
Joachim

biester
Specialist
Specialist

Unfortunately one cannot edit one's own posts any more - I forgot to attach the modified test.qvw.

Rgds,
Joachim

Not applicable
Author

Hi Joachim,

You are Great. Thanks

Fifth one is a little bit Spicy 😉

Regards

Sravan

biester
Specialist
Specialist

spicy but true. It took me two minutes to modify the expression so that it should work and another 20 minutes to find out why it DIDN'T work. I already wanted to give up when suddenly I hade a horrible suspicion ;-).

Rgds,
Joachim

Not applicable
Author

@ Joachim

It is good but as I am using it in a Nested If statement usage of Sum is giving a syntax error..It doesnot suit in the Syntax..

Not applicable
Author

Sorry for that. As I made the test example very fastly I made the Mistake..