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: 
Not applicable

if condition not working

Hi Experts,

I m trying to write if condition for a time like below in the script

if(DeliveryTime >= '10:00:00' and DeliveryTime <= '15:00:00' ,1,0) as Flag.

but this is not working. Is anything wrong in the expression?

Can someone please help

1 Solution

Accepted Solutions
sunny_talwar

Seems to be working for me

Table:

LOAD [Delivery Id],

    TimeStamp([Delivery Time]) as [Delivery Time],

    If(Frac([Delivery Time]) >= MakeTime(10) and Frac([Delivery Time]) <= MakeTime(15), 1, 0) as Flag

FROM

[..\..\Downloads\Time test.xls]

(biff, embedded labels, table is Sheet1$);

Capture.PNG

View solution in original post

20 Replies
ahaahaaha
Partner - Master
Partner - Master

Try

if(DeliveryTime >= Date('10:00:00') and DeliveryTime <= Date('15:00:00') ,1,0) as Flag.

trdandamudi
Master II
Master II

Your line of code should work, I just tried and it works:

if(DeliveryTime >= '10:00:00' and DeliveryTime <= '15:00:00' ,1,0) as Flag

Not applicable
Author

why should i use Date() here?

Not applicable
Author

its not working

ahaahaaha
Partner - Master
Partner - Master

overworked 🙂

if(DeliveryTime >= Time('10:00:00') and DeliveryTime <= Time('15:00:00') ,1,0) as Flag.

trdandamudi
Master II
Master II

I used the following sample code and it works:

Data:

Load *,

if(DeliveryTime >= '10:00:00' and DeliveryTime <= '15:00:00' ,1,0) as Flag;

LOAD * INLINE [

  Product,Color,SoldQty,DeliveryTime

    70060306, BLACK, 58,10:00:00

    70060306, BURGUN, 37,20:00:00

    70060306, MULTI, 18,20:00:00

    70380479, BLACK, 35,20:00:00

    70380479, BROWN, 35,20:00:00

    70380479, PINK, 13,20:00:00

    60190130, BLACK, 22,20:00:00

    60190130, NUDE, 35,20:00:00

    60190130, WHITE, 15,20:00:00

    70480047, BLACK, 45,20:00:00

    70480047, SILVER, 16,11:00:00

    70480047, WHITE, 8,15:00:00

    60360830, BLACK, 40,20:00:00

    60360830, NAVY, 12,20:00:00

    60360830, PINK, 16,20:00:00

];

sorrakis01
Specialist
Specialist

Hi,

How is the format of DeliveryTime in the script or in the original data?

Regards

Not applicable
Author

no not working

Not applicable
Author

it is hh:mm:ss format