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: 
senarath
Creator III
Creator III

Simple If condition not working at script level

Hi,

I'm trying to gross up with tax rate as below at script load. However, the rate that get applied is first rate that I have given which is 1.2571 and else condition rate of 1.2459 does not get calculated.

I get 1.2571 for the total period.

If([Business Date]<='12/31/2014',([Pkg Revenue]*1.2571),([Pkg Revenue]*1.2459)) as [Pkg Revenue]

I'm having 11.2 SR7 in the server. Any Idea....?

Thanks

Senarath

1 Solution

Accepted Solutions
avinashelite

Hi,

Please find the attachment for the solution .

The Expression is

If(Date([Business Date],'MM/DD/YYYY')<='12/31/2014',([Pkg Revenue]*1.2571),if(Date([Business Date],'MM/DD/YYYY')>='01/01/2015',([Pkg Revenue]*1.2459))) as [New Pkg Revenue]

View solution in original post

8 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

Then the if condition is always satisfied. Do you have any dates after Dec 31? If so, then check your date formatting, as either [Business Date] or '12/31/2014' are not being interpreted correctly as a date.

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Anonymous
Not applicable

Hi,

Try formatting date in Date#('12/31/2014', 'MM/DD/YYYY') in the condition instead of directing using it.

Anonymous
Not applicable

Hello,

try using date(date#([your date],'MM/DD/YYYY')).

HTH

avinashelite

Hi Senarath,

Please check whether dates after the 12/31/2014 is so then only the condition will get satisfied.

As Jonathan said check for the date format and covert both the date to same format like:

Date([Business Date],'MM/DD/YYYY')<='12/31/2014 this should work. If not please post your app with sample data

senarath
Creator III
Creator III
Author

Hi,

I applied date format also and did NOT work

If(Date#([Business Date],'MM/DD/YYYY')<='12/31/2014',([Pkg Revenue]*1.2571),if(Date#([Business Date],'MM/DD/YYYY')>='01/01/2015',([Pkg Revenue]*1.2459))) as [Pkg Revenue],

FIRST Rate get applied to all the period and not the second.

Pls find attached the excel data file FYI...!!!

Thanx

avinashelite

Hi,

Please find the attachment for the solution .

The Expression is

If(Date([Business Date],'MM/DD/YYYY')<='12/31/2014',([Pkg Revenue]*1.2571),if(Date([Business Date],'MM/DD/YYYY')>='01/01/2015',([Pkg Revenue]*1.2459))) as [New Pkg Revenue]

jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this

Date#() will give you the date in numeric format.

If(Date([Business Date],'MM/DD/YYYY')<='12/31/2014',([Pkg Revenue]*1.2571),if(Date([Business Date],'MM/DD/YYYY')>='01/01/2015',([Pkg Revenue]*1.2459))) as [Pkg Revenue],


OR


If(Date([Business Date],'MM/DD/YYYY')<=MakeDate(2014, 12, 31),([Pkg Revenue]*1.2571),if(Date([Business Date],'MM/DD/YYYY')>=MakeDate(2015, 1,1),([Pkg Revenue]*1.2459))) as [Pkg Revenue],


Hope this help you.


Regards,

Jagan.

senarath
Creator III
Creator III
Author

Hi All,

I found the issue. All the replies that you guys had posted apply correctly. However, I just verified that environmental variables in Main page is as default as I had customized date format as DD/MM/YYYY.

When I changed that to default, problem was solved.

Many thanks you guys.

Senarath