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: 
hopkinsc
Partner - Specialist III
Partner - Specialist III

Help with expression

Hi All,

I have a field 'TimeTaken' which holds the time taken to complete a job in the format of hh:mm:ss.

I want to sum another field (Completed_Flag) where the TimeTaken is less than 4 hrs.

Can anyone help please?

1 Solution

Accepted Solutions
tresesco
MVP
MVP

Try like:

=Sum(If(Hour(Time#(TimeTaken,'hh:mm:ss'))<4, Completed_Flag)

View solution in original post

10 Replies
tresesco
MVP
MVP

Something like:

=If(Hour(Completed_Flag)<4, Completed_Flag+TimeTaken)

its_anandrjs
Champion III
Champion III

Can you elaborate more about the fields details.

hopkinsc
Partner - Specialist III
Partner - Specialist III
Author

i get a null with that expression.

I thought it would be something like

Sum(Completed_Flag)

with some set analysis to say only look at the rows where TimeTaken is less than 4hrs

tresesco
MVP
MVP

How does the data look like in Completed_Flag field? Could you post a sample?

hopkinsc
Partner - Specialist III
Partner - Specialist III
Author

Hi Anand,

so the fields are as follows..

Completed_Flag which is either a 1 or 0

TimeTaken which is in the format of hh:mm:ss

So i want to sum the Completed_Flag where TimeTaken is less than 4hrs (04:00:00)

so if i have the following...

OrderNumber                   Completed_Flag                      TimeTaken

1000                                        1                                         02:14:25

1001                                        1                                          05:53:11

1002                                        0                                         01:10:07

I would only want OrderNumber 1000 and 1002 to be included in my result, the result would be 1 because 1002 has a 0 for the Flag.

Does that make sense?.

jagannalla
Partner - Specialist III
Partner - Specialist III

Hi,

Take the dimension as =If(Hour(TimeTaken)<4,Order)

and expression as Sum(Completed_Flag)

Cheers!!

Jagan

tresesco
MVP
MVP

Try like:

=Sum(If(Hour(Time#(TimeTaken,'hh:mm:ss'))<4, Completed_Flag)

its_anandrjs
Champion III
Champion III

Try with this

Sum(If( Hour(TimeTaken,'hh') < 4, Completed_Flag)

its_anandrjs
Champion III
Champion III

Try with this expression


Sum(If( Hour(TimeTaken,'hh') < 4, Completed_Flag)