Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi guys,
I wonder if it is possible to get things working here. What I need to know is, if it is possible to get your If-Statement answers replaced by variables already defined.
E.g:
LOAD
Price,
Article,
If(Year = ('A'), x, y)
FROM
C:\,,,
Variables:
for x = CurrentYear =Year(today())
for y = PreviousYear =Year(today()-365)
Thanks,
You should define the variables with 'Let' keyword. Something like this...
Let vCurrentYear =Year(today())
And you can call the variables by using the below syntax...
=$(vCurrentYear)
I hope this helps!
Please read the below post. I had used variables as user defined functions by passing the input value and returning a scalar value as output. I hope this should help you...
http://community.qlik.com/forums/t/43601.aspx
You can also post sample QV document with fictitious data and one of us will help you...
You should define the variables with 'Let' keyword. Something like this...
Let vCurrentYear =Year(today())
And you can call the variables by using the below syntax...
=$(vCurrentYear)
I hope this helps!
Writing an '=' before the $ makes the Synthax light up red!
Thats how I typed it in:
If(Year = ('A'), $(CurrentYear), $(PreviousYear))
You don't have to use the "=" sign before the variable.
In you case you will have to do the next:
if ( Year = 'A' , $(CurrentYear) , $(PreviousYear) )
With the Let statement it works just fine!
Thank you all
I am assuming that you are declaring the variable before the Load Script (Because QV reads from Left to Right and Top to Bottom). Please don't use the '=' in the load script and try using ($(vCurrentYear)) instead of $(vCurrentYear)