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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Sum of Time Measure

Hello,

I am having #ShiftStartTime/#ShiftEndTime of a Employee say XYZ.

I want to show total no. of hours of XYZ from this time measure. I am using sum(#ShiftEndTime-#ShiftStartTime) but its not working.

Can some body suggest to me what I can do in this case?

Regards,

Balraj

9 Replies
crusader_
Partner - Specialist
Partner - Specialist

Hi,

What exact result gives your expression?

'-' or '0,12312' or smth else.

Try

Interval( sum(#ShiftEndTime-#ShiftStartTime) )

Regards,

Andrei

jagan
Partner - Champion III
Partner - Champion III

Hi,

Try like this

Load

*,

Num(Interval(ShiftEndTime - ShiftStartTime, 'h')) AS Hours

FROM DataSource;

Now use this expression

=Sum(Hours)

Regards,

Jagan.

Anonymous
Not applicable
Author

Hello Andrei,

Its not working, still its giving 1 with your expression else 0.

Regards,

Balraj

anbu1984
Master III
Master III

What is the time format in #ShiftEndTime and #ShiftStartTime?

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

It depends on what you actually have in these two fields (the underlying value, not the displayed value). If they are normal date/time/timestamp fields, then the time portion is a fraction of a day. To get the interval in hours (not just display in hours), use

    (#ShiftEndTime-#ShiftStartTime) * 24   (in hours)

    (#ShiftEndTime-#ShiftStartTime) * 1440 (in minutes 1440 = 24*60)


To display in hh:mm (the underlying value does not change, just the display format) use:


    interval((#ShiftEndTime-#ShiftStartTime) * 24, 'hh:mm')


HTH

Jonathan



Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
crusader_
Partner - Specialist
Partner - Specialist

Can you share a qvw sample?

Andrei

Anonymous
Not applicable
Author

Hello Jagan,

Will it work for minutes?

Regards,

Balraj

Anonymous
Not applicable
Author

Jonathan,

Time is into 24 hr format, but your expression is not working.

Regards,

Balraj

jagan
Partner - Champion III
Partner - Champion III

Hi,

Try like this for minutes

Load

*,

Num(Interval(ShiftEndTime - ShiftStartTime, 'm')) AS Minutes

FROM DataSource;

Now use this expression

=Sum(Minutes)

Regards,

Jagan.