Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Count rows per group

Hi,

I need to count the rows per group as shown below. How can I do this?

IdIdDim2IdDim3Row
A1020131
B1020121
B1120122
C1020111
D1220131
D1320132
D1520133
D2220114
E1120121
E4120132

I

1 Solution

Accepted Solutions
Gysbert_Wassenaar

See attached example. There's a hidden calculated dimension that makes this work.


talk is cheap, supply exceeds demand

View solution in original post

8 Replies
Gysbert_Wassenaar

Like this:

Temp:

load Id, IdDim2, IdDim3

from ...mysource...;

Result:

load Id, IdDim2, IdDim3,

if(Id=previous(Id),rangesum(1,peek(Row))) as Row

resident Temp

order by Id, IdDim2;


talk is cheap, supply exceeds demand
Not applicable
Author

Thanks for the reply, but I need it on a straigh table, because the classification may change dynamically, may be by id, iddim2, iddim3 or id, iddim3, iddim2.

Gysbert_Wassenaar

aggr(RowNo(),Id,IdDim2) for your example. Change the dimensions rowno() should be aggregated over if you use other dimensions.


talk is cheap, supply exceeds demand
Not applicable
Author

Why the column IdDim3 doesn´t show all results?

test.JPG

Gysbert_Wassenaar

Because in your data, unlike in the sample data in your first post, there is only one unique combination of Id and IdDim2 for B: B, 10. In your first post you have B,10 and B,11.


talk is cheap, supply exceeds demand
Not applicable
Author

I changed it for another test, when added to iddim3 I could not count rows.

test.JPG

Gysbert_Wassenaar

See attached example. There's a hidden calculated dimension that makes this work.


talk is cheap, supply exceeds demand
Not applicable
Author

Very thanks.