Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to use variable with date?

Hi,

I defined variable vTestTest = tomorrows date (14/06/2017)

snap.JPG

Then I put the following measure in 'text' object:

=if($(vTestTest)>today(), 'yes', 'no')

The result is no...

Any ideas why?

1 Solution

Accepted Solutions
sunny_talwar

Try it without dollar sign expansion

=If(vTestTest > Today(), 'yes', 'no')

View solution in original post

5 Replies
sunny_talwar

Try it without dollar sign expansion

=If(vTestTest > Today(), 'yes', 'no')

Anonymous
Not applicable
Author

Ok, it works:)

But - on Qlik's tutorials it has been said to use variables as $(variable)

Why in this case I have to use without $()? What is the rule?

sunny_talwar

Seems like your vTestTest is hardcoded to be 14/06/2017... which doesn't need expansion here... in fact when you expand it, performs a divison 14 divided by 06 divided by 2017....

Not an experts on variables, but this

MakeDate(2017, 6, 14) as your variable and then this (with dollar sign expansion)

=If($(vTestTest) > Today(), 'yes', 'no')

Anonymous
Not applicable
Author

Thanks Sunny:)

You're right - it seems that QS sees this variable as 14 div. by 6 div by 2017...

It's strange, because I have used the same variable, in the measure below:

=count({<Completed ={"<=$(vTestTest)"}>} distinct CandidatesID)

And... - it works properly!

What is more - if you remove $() - the formula above will NOT work.

Anyone knows why one time I have to use $() and another time without $()?

sunny_talwar

To me, variables are very confusing and I barely use them... but may be check this out

The Magic of Dollar Expansions

The Magic of Variables

The Little Equals Sign