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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

AGGR() with calculated Time field

Hi,

I'm have real problems trying to Aggr results when I add a time element.

Below is a sample table;

Sample table 1.png

3 fields need to be calculated using Aggr (i believe) as Employee 2 appears twice the results of the 3 transaction fields for employee 2 are duplicated using a standard Sum/Count expression.  If I use an Aggr expression then I get the results as seen above.

If I add a 2nd aggr level by adding ClockInDate to therefore make each row unique I get No result just blank for all rows.

# Transactions Handled

=concat(Aggr(Count(%_TransactionID),[Employee Name]))

Net of Transactions Handled

=Sum(Aggr(sum([Net Sales Before Discount]),[Employee Name]))

Avg Net Per Transaction

=Sum(Aggr(sum([Net Sales Before Discount])/Count(%_TransactionID),[Employee Name]))

ClockInDateClockOutDate
20/01/2017 06:45:0020/01/2017 16:13:00
20/01/2017 10:00:0020/01/2017 13:57:00
20/01/2017 16:02:0020/01/2017 23:39:00
20/01/2017 17:24:0020/01/2017 23:37:00

ClockInDate and ClockOutDate are datetime fields and Time(ClockInDate ,'hh:mm:ss') is used for the results table at the top Shift Length is calculated as Time([ClockOutDate]-[ClockInDate],'hh:mm:ss')

If any of these Time expressions are used in the Aggr the Aggr does not work.

1 Solution

Accepted Solutions
sunny_talwar

I think you are right.... you need to figure out if the join is correct or not....

View solution in original post

18 Replies
sunny_talwar

Are you using  Clock In Date, Clock Out Date and Shift Length as dimensions or expressions? Also is Transaction date a date field or a time field? The reason I ask this is because, you need unique dimension to remove duplicate Employee Name. Clock In Date, Clock Out Date and Shift Length are def. not unique and will lead to seeing multiple rows if used dimensions

jpbourse74
Contributor II
Contributor II

With the column Clock in Date and Clock out Date, it is not possible. Option 1: If you can delete these two columns and leave the sum of the times between Clock in Date and Clock out date per employee. Option 2: Remove the two previous columns and make the sum or count without the aggr. Then if I want to know every employee of what hour at what time I work I enter the employee and add a size of groups. I hope it is useful. regards

Anonymous
Not applicable
Author

Hi Sunny,

Yes Time(ClockInDate,'hh:mm:ss') and Time(ClockOutDate,'hh:mm:ss') are used as calculated dimensions.

The date part (which is removed is the same as shown for TransactionDate but the time element is different, this puzzled me as to why its not seeing the time as unique.

Anonymous
Not applicable
Author

Hi Juan,

Really need to have both Clock times as part of control reporting.

sunny_talwar

May be use them as expressions instead of dimensions because they are different for the two rows of Employee and your dimension would show them in two different rows?

But even as an expression, how do you plan to show these times? Sum them? Avg them? Min or Max?

girirajsinh
Creator III
Creator III

Hi John

Try following for

# Transactions Handled

=concat(Aggr(Count(%_TransactionID),[Employee Name],ClockOutDate,ClockInDate))

disable other two expressions for now and check what you get from above expression

Anonymous
Not applicable
Author

Hi Girirajsinh,

This is one of the combinations I tried previously.  Applied just this expression with all other expressions disabled, all other fields (first 5) are dimensions.

Employee Name Transaction Date Clock In Date Clock Out Date Shift Length concat(Aggr(Count(%_TransactionID),[Employee Name],ClockOutDate,ClockInDate))
Employee 120/01/201706:45:0016:13:0009:28:0067
Employee 220/01/201710:00:0013:57:0003:57:00177
Employee 220/01/201717:24:0023:37:0006:13:00177
Employee 320/01/201716:02:0023:39:0007:37:00215
sunny_talwar

What is the output you are looking to get? Just one row for each Employee Name?

vinieme12
Champion III
Champion III

Try

Aggr(NODISTINCT Count(%_TransactionID),[Employee Name])

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.