Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
danielnevitt
Creator
Creator

Adding variable date field to an expression

Hi,

I have the following Expression and I would like to replace the hard coded date with a variable vToday.

vToday = Date(Today())   - This is already set as a variable

FABS(SUM( IF(TRADE_TYPE='Swap' AND BS_IND='Fixed' AND INTERNAL_IND='-' AND FINAL_PRICING_DT>='06/03/2014', PAYMENT_QTY*(-PRICE1) , IF(TRADE_TYPE='Swap' AND BS_IND='Float A' AND INTERNAL_IND='-' AND FINAL_PRICING_DT>='06/03/2014',PAYMENT_QTY*PRICE2 ,0 ) )))

Any help with this will be much appreciated.

Regards,

Daniel

8 Replies
tresesco
MVP
MVP

Replace your '06/03/2014' with $(vToday)

danielnevitt
Creator
Creator
Author

Hi,

Thanks for the reply.

Unfortunately that suggestion doesn't work.  Am I missing some () further on in the expression?

Regards,

Daniel

rustyfishbones
Master II
Master II

Can you share the App?

Not applicable

Daniel,

1) Check the formats of the different dates: I think they must be the same for QV to work properly (that is the case in set analysis)

2) If the format is the same, try to use num() especially for your variable vToday = num(today())

Fabrice

MK_QSL
MVP
MVP

The Format of FINAL_PRICING_DT and vToday should be same.

Consider that FINAL_PRICING_DT is 'DD-MM-YYYY' and vToday = 'DD/MM/YYYY'

Do as below...


FINAL_PRICING_DT =  {'$(=Date(Date#(vToday,'DD/MM/YYYY'),'DD-MM-YYYY'))'}

fernando_tonial
Employee
Employee

Hi,

Please, replace your '06/03/2014' with '$(vToday)'

Set a Variable in script:

SET vToday = Date(Today(),'DD/MM/YYYY');

Best Regards.

Tonial.

Don't Worry, be Qlik.
Not applicable

Hi Danel,

Are u sure the field FINAL_PRICING_DT values are same as the values in defined variable ,

If those are fine ..it works ,You didn't miss anything if u do that..

Not applicable

Any news of all that ?

vToday = num(today()) is certainly the best choice because the variables are not dual (all fields in QV are dual like date, integers but variables are not). By storing an integer with the num() function, you force the > operator to use the integer part of the date.

Fabrice