Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
fcecconi
Partner - Creator III
Partner - Creator III

Qlik Sense Variable Help

I am having a little issue

I have a variable that allows the user to input a date (vTodate).

I then have variable (test) that converts the input to a number             =Num(Date(vToDate,'M/D/YYYY'))

In my load script, I am doing             Num(Date(TransactionDate,'M/D/YYYY'))                        as TransDateNum

I created 1 more variable (Include)                                                        =if(TransDateNum < $(test) ,'L','G')

The value is never L

Thanks for your assistance.

1 Solution

Accepted Solutions
MK_QSL
MVP
MVP

You can try without creating test variable..

try

=if(TransDateNum < '$(vTodate)', 'L','G') as YourFieldName

View solution in original post

8 Replies
MK_QSL
MVP
MVP

have you tried

'$(test)'

fcecconi
Partner - Creator III
Partner - Creator III
Author

Yes, no change

fcecconi
Partner - Creator III
Partner - Creator III
Author

I was able to get the variable to change values, but only when selecting a transaction date.  I don't want to have to do this if possible.

JustinDallas
Specialist III
Specialist III

Is there something peculiar about your process that you're not telling us?  It seems to work for me, at least at a preliminary level.

LET vToDate = Today()

;

LET vToDateNum = Num(Date(vToDate,'M/D/YYYY'))

;

TRACE 'vToDateNum' & $(vToDateNum)

;

DATA:

LOAD *,If(TransactionDate2 < $(vToDateNum) ,'L','G') AS 'TestValue'

;

LOAD Num(Date(TransactionDate,'M/D/YYYY')) AS 'TransactionDate2'

;

LOAD * Inline

[

'TransactionDate'

    '3/11/2018'

    '3/12/2018'

    '3/14/2018'

    '3/16/2018'

    '3/19/2018'

    '3/30/2018'

]

;

LET vNumberOfRows = NoOfRows('DATA')

;

TRACE $(vNumberOfRows)

;

EXIT Script

;

MK_QSL
MVP
MVP

You can try without creating test variable..

try

=if(TransDateNum < '$(vTodate)', 'L','G') as YourFieldName

dwforest
Specialist II
Specialist II

Try using floor() instead of num(); not sure if the Date formatting actually strips the time value (if there is one).

I am assuming that you have all three items in a table with your data to see it's never 'L' when it should be.

fcecconi
Partner - Creator III
Partner - Creator III
Author

Justin

The variable on in the application and not the load script.  I am using a variable extension to capture the user input and store it in a variable.  I then want to use that variable and compare it against a object in the table and store the result as a variable.

Odd this is the logic works fine as a master measure.

fcecconi
Partner - Creator III
Partner - Creator III
Author

That worked!

thanks