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

Announcements
Independent validation for trusted, AI-ready data integration. See why IDC named Qlik a Leader: Read the Excerpt!
cancel
Showing results for 
Search instead for 
Did you mean: 
martyn_birzys
Creator
Creator

Aggregation in script

I have data which looks like this:

   

ContractIDCustomerContract End
AJohn30/06/2016
BJohn30/01/2016
CJohn30/06/2016
ARobert30/06/2016
BRobert30/03/2016
BDavid30/06/2016
CDavid30/01/2016

And require to script a table that would look like this:

   

Contract EndContractIDQtty Contracts Ending
30/01/2016B1
30/01/2016C1
30/03/2016B1
30/06/2016A2
30/06/2016C1
30/06/2016B1

I tried using aggr(), it is easy when there is only one dimension, but I need to aggregate per Date per ContractID, and do that through script. Suggestions, please?

3 Replies
petter
Partner - Champion III
Partner - Champion III

LOAD

  [Contract End],

  [ContractID],

  Count(Customer)

RESIDENT

  Data

GROUP BY

  [Contract End],[ContractID];

sunny_talwar

Aggregation in script is done using group by statement. Try this script:

Table:

LOAD * Inline [

ContractID, Customer, Contract End

A, John, 30/06/2016

B, John, 30/01/2016

C, John, 30/06/2016

A, Robert, 30/06/2016

B, Robert, 30/03/2016

B, David, 30/06/2016

C, David, 30/01/2016

];

Join(Table)

LOAD ContractID,

  [Contract End],

  Count(Customer) as [Qtty Contracts Ending]

Resident Table

Group By ContractID, [Contract End];


Output:


Capture.PNG

petter
Partner - Champion III
Partner - Champion III

LOAD

  [Contract End],

  [ContractID],

  Count(Customer)

FROM

  Data.XLS (ooxml....)

GROUP BY

  [Contract End],[ContractID];