Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
alespooletto
Creator
Creator

Obtain average working hours by employee in load editor script instead of measure

Hello, I currently have the following measure that does a check on the average sum of worked hours by employee regardless of date.

AvG(Aggr({< Weekday = {'Lu', 'Ma', 'Me', 'Gi','Ve'}, LABOR=>} =IF( LongShift = 0 , Sum(Duration)), Date, LABOR))

 

I would like to do this in the load editor script instead, but so far I was only able to work through it with a second table that sort of messes up my model.

 

LABOR_AGGR:
Load
    Time(LABOR_LOG_END - LABOR_LOG_START) as Duration,
    LABOR,
    Date_log as Data_Labor,
    Interval(Avg(Duration))
Resident LABOR_LOG
GROUP BY LABOR, Date_log;

 

 

 

 

Labels (1)
1 Reply
edwin
Master II
Master II

you may want to explore something like this:

Load
    LABOR,
    Data_Labor,
    Duration,
    Duration/Count as Average;
Load
    sum(LABOR_LOG_END - LABOR_LOG_START) as Duration,
    count(LABOR) as Count,
    LABOR,
    Date_log as Data_Labor
Resident LABOR_LOG
WHERE LongShift = 0
GROUP BY LABOR, Date_log;


i added the where clause to simulate what you have in your expression.  assuming Longshift is in the same table.  this returns number of days so if you need it in hours, you multiply it by 24

sum(LABOR_LOG_END - LABOR_LOG_START)*24 as Duration

you may not want to use time function