Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
master_student
Creator III
Creator III

condition

Hello

I need to set a condition in my expression to display the time only if it is >13:00:00 and <14:00:00

If(time(DATE_DEB)>'13:00:00', and time(DATE_DEB)>'13:00:00', '')

DATE_DEB has this format : 12/01/2016 12:32:55

any idea please

11 Replies
marcus_sommer

I would use hour/minute/second as fields within the datamodel. You could simply use:

hour(DATE_DEB) as Hour

or add a master timetable: The Master Time Table

and from this Hour your could create a flag-field, like:

if(hour(DATE_DEB) = 13, 1, 0) as HourFlag

or using Hour within a set analysis, like:

sum({< Hour = {13}>} value)

- Marcus

sunny_talwar

May be this:

If(Frac(TimeStamp#(DATE_DEB, 'DD/MM/YYYY')) > MakeTime(13) and Frac(TimeStamp#(DATE_DEB, 'DD/MM/YYYY'))< MakeTime(14), Time(TimeStamp#(DATE_DEB, 'DD/MM/YYYY')))

holmlund
Contributor III
Contributor III

If(Frac(DATE_DEB)> (13/24) and Frac(DATE_DEB)<(14/24), Time(DATE_DEB))

master_student
Creator III
Creator III
Author

nothing as a result

master_student
Creator III
Creator III
Author

did as you said , if (HourFlag=1,Hour) but i get result like that :

Capture.PNG

marcus_sommer

The field Hour looked like a time and not a hour. How is Hour and HourFlag created?

- Marcus

Not applicable

Hi,

Can you please try below and let me know if it is fine.

if(replace(mid(a, Index(a,' ')+1),':','')>130000 and replace(mid(a, Index(a,' ')+1),':','')<140000,'',a)

Here,  'a' is the column

Thanks,
Sreeman

miguelbraga
Partner - Specialist III
Partner - Specialist III

Hey there mate,

If you can make changes in the script you can make it something like this:

Table:

LOAD *,

               Flag_Greater13 * Flag_Lesser14 as Flag

LOAD *,

               if(hour(DATE_DEB) > 13, 1, 0) as Flag_Greater13,

               if(hour(DATE_DEB) < 14, 1, 0) as Flag_Lesser14;

LOAD *

FROM [your connection to your database goes here];

Then use the Flag field in your set analysis like this:

=sum({$< Flag= {1}>} value)

This is by far the best option because you bring the complexity to the script which increases the rendering perfomance in your table if you have millions of rows and it's easy to understand

Best regards,

D.A. MB

master_student
Creator III
Creator III
Author

i have to use time not hour