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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Group (or aggregate) by n records in Qlikview?

Hi experts,

In SQL server, I can summarize data by a fixed number of records using the query blew. I want to do the same thing in Qlikview, for example to group every 100 records (previously sorted in ascending order by date) and then aggregate results with AVG. I do not know whether it can be done, Please helps.

Thanks

WITH T AS (
 
SELECT RANK() OVER (ORDER BY ID) Rank,
    P
.Field1, P.Field2, P.Value1, ...
 
FROM P
)
SELECT (Rank - 1) / 100 GroupID, AVG(...)
FROM T
GROUP BY ((Rank - 1) / 100)
;

1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

See here. That solution requires a macro so it may not work correctly in the ajax client.


talk is cheap, supply exceeds demand

View solution in original post

3 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Maybe with the ceil function:

Result:

load GroupID, avg(FieldX)

group by GroupID;

load *, ceil(recno(),100) as GroupID

from ...presortedtable...;


talk is cheap, supply exceeds demand
Not applicable
Author

Thanks and sorry about the late response.

I would like to know whether it can be done at expression level. I want users to be able to specify the groups in the front end.

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

See here. That solution requires a macro so it may not work correctly in the ajax client.


talk is cheap, supply exceeds demand