Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Time Calculations

Hi All

I need to find out how I can multiply a number of hours by expected personnel, to get total hours booked to event.  the calculation to get the Hours are

if(interval(EndTime - StartTime,'hh:mm')<0, interval(Date(EndTime,'ddmmyy')+1 - StartTime,'hh:mm'),interval(EndTime - StartTime,'hh:mm') )as [Total_Hours] and the personnel Expected is a sum of numbers.  so the total booked hours should be 21:00, but I cant workout how I can calculate a time calculation by a number calculation. am i missing something

can anyone help.

Capture.JPG.jpg

thanks in advance

1 Solution

Accepted Solutions
jebamalai
Valued Contributor

Re: Re: Time Calculations

Oh sorry.

Pfa the updated one

15 Replies
MVP
MVP

Re: Time Calculations

Could you post your sample qvw?

Employee
Employee

Re: Time Calculations

First, you have too many formatting functions in your expression. Remove them: They do not change the calculations; they just prevent you from seeing the structure of your expression. Instead of

     If(  interval(EndTime - StartTime,'hh:mm')<0,

          interval(Date(EndTime,'ddmmyy')+1 - StartTime,'hh:mm'),

          interval(EndTime - StartTime,'hh:mm')

          ) as [Total_Hours]

you should write

     Interval(

          If(  EndTime - StartTime <0,

               EndTime +1 - StartTime,

               EndTime - StartTime ),

          'hh:mm' ) as [Total_Hours]

If you want to format it, you should put the formatting function as the outermost function.

Secondly, if EndTime and StartTime are correctly interpreted, they have numeric values where a difference of one day is 1, and a difference of one hour is 1/24. This means that you can get the number of hours through

     (EndTime - StartTime) * 24

HIC

Not applicable

Re: Time Calculations

Hi tresesco

I have attached an example now.

thanks

MVP
MVP

Re: Time Calculations

user id, password?

senpradip007
Valued Contributor III

Re: Time Calculations

Can you share the credentials to login to your application?

jebamalai
Valued Contributor

Re: Time Calculations

I was trying open your sample document but it was asking the user ID

try with below

Expected hours = Personel expected*(Totalhours*24)

In total hours you can use your actual expression

Not applicable

Re: Time Calculations

Hi sorry about that i forgot it had section access. i have remove this now and re-uploaded

thanks in advance

jebamalai
Valued Contributor

Re: Time Calculations

I tried and it worked

DDT_Hours*24)*[Personnel Expected]

Not applicable

Re: Time Calculations

Hi Jebamalai

thanks for taking a look,i need the output to be formated to hh:mm.  can you help?

regards

James

Community Browser