Count a GroupBy

  

Hi All,

Trying to count a GroupBy:

Rather than getting a count for each Group I want a count of the groups (so in this example the count should be 3). 

Helena Lameiro wrote:

André,

You are counting the number of Na... (records stard with An...)  per Project Name (records end with ...Solar#). Just do a count on the ProjectName attribute (you only have 3, isn't it:   ...solar1, ...solar2, ...solar 3), instead of counting P... and group by ProjectName.

Restart with a clean aggregate (delete the generate count attribute on the aggregate) 

Hi Helena,

Tried that, it gives me 12... 5+4+3  That is why I was trying to count the groupby, any ideas?

Solution

Hi André,

The aggregate list has a length. Isn't that what you need? This will not work if the aggregate is being used in a tablerecord since outsystems will do some performance enhancements that mess with this.

Regards,

Marcelo

Solution

Marcelo takes the medal :) Thank you both.

André,

I noted that my answer was wrong (but not on time...), wanted to correct it suggesting you to use an advanced query with Select Count (Distinct {Project}.[Name]). I didn't entered my reply and meanwhile I had some issues of mine to resolve.

Marcelo's Solution, though is far more simple and efficient!

Just a bit of seasoning to Marcelo's Solution. Instead of Length, use the Count Output of the aggregate. Length depend on the case you are using the aggregates, count doesn't.

@Helena,

Let me just say that Count, in general, should be used only for pagination purposes.

In most scenarios Length will cover these type of things (total number of lines).

And if André already has all the results, Length will be the best option.