Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
adiarnon
Creator III
Creator III

sum problem

hi'

i have this table -

custdatehours
A1.1.149
B2.1.149
C3.1.149
A1.1.149
C2.1.149

I WANT TO GET THIS -

CUSTHOURS
A9
B9
C18

I WANT IT TO SUM FOR EACH CUST THE HOURS BUT ONLY FOR DISTINCT DATES.

LIKE- 'A' have two records with the date -1.1.14 so it need to count it only once...

hope its clear

TNX

16 Replies
Not applicable

Check this ...

anbu1984
Master III
Master III

LIke this

er_mohit
Master II
Master II

see the attached file

adiarnon
Creator III
Creator III
Author

i cant open the files =(

can someone explain in word the solution?

adiarnon
Creator III
Creator III
Author


not working )=

jerem1234
Specialist II
Specialist II

Hello, I used the formula:

sum(aggr(firstsortedvalue(distinct hours, -hours), cust, date))

This will get the highest hours for a date (if they happen to be different for instance if you had A 1.1.14 to have 9 and 11 for hours), then sum all the hours for the different dates for a customer. I believe this is what you are looking for. Then work hours is:

sum(work_hours)

Please find attached.

anbu1984
Master III
Master III

Script:

-------------------------------------------------------------

Tab1:

Load * Inline [

cust,date,avail_hours,work

A,1.1.14,9,2

B,2.1.14,9,3

C,3.1.14,9,4

A,1.1.14,9,5

C,2.1.14,9,6 ];

Final:

Load *,If(RowNo() <> 1 And cust = Previous(cust) And date = Previous(date),1,0) As Ind Resident Tab1 order by cust,date;

Drop table Tab1;

-------------------------------------------------------------

Use these expressions in front end

sum(If(Ind=0,avail_hours))

sum(work)