Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

fcecconi
Contributor II

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

Re: Qlik Sense Variable Help

You can try without creating test variable..

try

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

8 Replies

Re: Qlik Sense Variable Help

have you tried

'$(test)'

fcecconi
Contributor II

Re: Qlik Sense Variable Help

Yes, no change

fcecconi
Contributor II

Re: Qlik Sense Variable Help

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
Valued Contributor

Re: Qlik Sense Variable Help

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

;

Re: Qlik Sense Variable Help

You can try without creating test variable..

try

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

dwforest
Valued Contributor

Re: Qlik Sense Variable Help

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
Contributor II

Re: Qlik Sense Variable Help

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
Contributor II

Re: Qlik Sense Variable Help

That worked!

thanks