Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

If condition needs a modification

Hi,

I have a table where start time and end time with date available.

St Dtst Timeend dtend time
11/11/118:20:12 AM11/11/1110:00:20 PM
11/11/116:20:12 AM11/12/118:00:20 PM
11/11/1110:20:12 AM11/15/116:00:20 PM
11/11/112:20:12 PM11/11/115:00:20 PM

In the chart,I am trying to do some calculatation on those time range which belong to 7AM to 7PM.Expected result would be

 

St DtSt timeend dtend timecalc
11/11/118:20:12 AM11/11/1110:00:20 PMexceed Range 7 AM to 7 PM
11/11/116:20:12 AM11/12/118:00:20 PMexceed Range 7 AM to 7 PM
11/11/1110:20:12 AM11/15/116:00:20 PMcalculated value
11/11/112:20:12 PM11/11/115:00:20 PMcalculated value


I have two variables

Set vStart=maketime(7);

Set vEnd=maketime(19);

For the Calc I am using

if (Start_Time < $(vStart) or End_time >$(vEnd),'exceed Range 7 AM to 7 PM',Time(Tot_Hrs-NonWork_Hrs) ) as calc;

the above if condition is not working.Can someone help on this?

Thanks,Pooja

1 Solution

Accepted Solutions
brenner_martina
Partner - Specialist II
Partner - Specialist II

Hi, Pooja,

your script must look like this:

let vStart=Num(maketime(7));
let vEnd=Num(maketime(19));

LOAD
Start_Date,
Start_Time,
End_Date,
End_Time,
if (Num(Start_Time) < $(vStart) or Num(End_Time) >$(vEnd),'exceed Range 7 AM to 7 PM',Time(End_Time-Start_Time) ) as calc

INLINE [
    Start_Date, Start_Time, End_Date, End_Time
    11.11.2011,  8:20:12 AM, 11.11.2011, 10:00:20 PM
    11.11.2011,  6:20:12 AM, 11.12.2011,  8:00:20 PM
    11.11.2011, 10:20:12 AM, 15.11.2011,  6:00:20 PM
    11.11.2011,  2:20:12 PM, 11.11.2011,  5:00:20 PM
];

Greetings from Germany

Martina

EVACO GmbH

View solution in original post

2 Replies
brenner_martina
Partner - Specialist II
Partner - Specialist II

Hi, Pooja,

your script must look like this:

let vStart=Num(maketime(7));
let vEnd=Num(maketime(19));

LOAD
Start_Date,
Start_Time,
End_Date,
End_Time,
if (Num(Start_Time) < $(vStart) or Num(End_Time) >$(vEnd),'exceed Range 7 AM to 7 PM',Time(End_Time-Start_Time) ) as calc

INLINE [
    Start_Date, Start_Time, End_Date, End_Time
    11.11.2011,  8:20:12 AM, 11.11.2011, 10:00:20 PM
    11.11.2011,  6:20:12 AM, 11.12.2011,  8:00:20 PM
    11.11.2011, 10:20:12 AM, 15.11.2011,  6:00:20 PM
    11.11.2011,  2:20:12 PM, 11.11.2011,  5:00:20 PM
];

Greetings from Germany

Martina

EVACO GmbH

Not applicable
Author

Thanks a lot!