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

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

group by - aggregation table

HI,

I have the following table loaded:

W/CMediumKeywordVisitors Visits
1M1K111
1M1K111
2M1K111
2M2K211
2M2K211

I would like to have a new table aggregated by W/C, Medium and Keyword which would look like this(Visitors and Visits would use Sum function):

W/CMediumKeywordVisitors Visits
1M1K122
2M1K111
2M2K222

Anyone could help me to write a script for it, please?

Thanks.

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

This script will do that:

LOAD [W/C],

          Medium,

          Keyword,

          Sum(Visitors) As Visitors,

          Sum(Visits) As Visits

Resident Table

Group By [W/C], Medium, Keyword

;

Where Table1 is the name of the first table (change as required).

Note that as shown above, you will land up with a synthetic key at the end of the load. The resolution of this will depend on what you are planning to do with the aggregate table.

Are you sure that you want to do this in script? It would be easy enough to calculate these aggregates in a straight table or pivot table.

Hope that helps

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

3 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

This script will do that:

LOAD [W/C],

          Medium,

          Keyword,

          Sum(Visitors) As Visitors,

          Sum(Visits) As Visits

Resident Table

Group By [W/C], Medium, Keyword

;

Where Table1 is the name of the first table (change as required).

Note that as shown above, you will land up with a synthetic key at the end of the load. The resolution of this will depend on what you are planning to do with the aggregate table.

Are you sure that you want to do this in script? It would be easy enough to calculate these aggregates in a straight table or pivot table.

Hope that helps

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Thank Jonathan.

It is very helpful. I think you are right with the calculations in a table rather than script. The end result of the excercise  is a chart based on the aggregated values not the aggregated table. Is it possible to do without writing script for it?

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

It is possible - to do so, create a straight table or pivot table with dimensions [W/C], Medium, Keyword, and expressions

Sum(Visitors) and Sum(Visits) As Visits.

Regards

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein