Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
hanna_choi
Partner - Creator
Partner - Creator

Aggr Function

Hello.

I'm Testing with Qlik Sense June 20018.

When I used Aggr function, I was found problem.

Why the Aggr function return wrong results?

What do I do for right result?

aggr error.PNG

1 Solution

Accepted Solutions
nsetty
Partner - Creator II
Partner - Creator II

Hi Hanna,

Can you try dumping AGGR virtual table entries onto textbox object and verify why you were getting 22 records.

=concat(aggr(sum(sales), Country), '|')


Also, mark helpful/answered if you agree with a solution


Thanks

Nagesh

View solution in original post

8 Replies
Gysbert_Wassenaar

Why do you think the result is wrong? Because you have 21 countries and the count(aggr... returns 22? Check for sales that don't have a country.


talk is cheap, supply exceeds demand
hanna_choi
Partner - Creator
Partner - Creator
Author

Hello  Gysbert Wassenaar

The Aggr means the copunt of country that has the sum of sales. Is it my misunderstand? I think Even though some country would have no sales,  but the sales have to include the country.

So I thought the result is wrong.

I checkd the count of sales. I don't know why it is 22.

country sales.PNG

nsetty
Partner - Creator II
Partner - Creator II

Try using Distinct keyword

and also dumping Aggr contents onto text box.

=concat(aggr(sum(sales), Country), '|')

Gysbert_Wassenaar

If you want a count of countries that have sales you should use this:

count({<Country={"=sum(Sales)>0"}>}distinct Country)


talk is cheap, supply exceeds demand
dx_anupam
Creator
Creator

Hi Hanna,

It seems to be you have some null values in country column and which is causing discrepancy in both count.

Please uncheck the tick mark next to "suppress when value is null" under dimension for straight table.

Regards,

Anupam 

hanna_choi
Partner - Creator
Partner - Creator
Author

Thanks you everyones.

It is mystery.

After = count({<Country={"=sum(Sales)>0"}>}distinct Country),
I got the 21.

THe country is not include NULL values. I unchecked include null value option

aggr count.PNG

nsetty
Partner - Creator II
Partner - Creator II

Hi Hanna,

Can you try dumping AGGR virtual table entries onto textbox object and verify why you were getting 22 records.

=concat(aggr(sum(sales), Country), '|')


Also, mark helpful/answered if you agree with a solution


Thanks

Nagesh

hanna_choi
Partner - Creator
Partner - Creator
Author

HI Nagesh Setty

Thank you for your anwser.

I found the 0(zero)

But I don't know why 0 is made and what country include 0.

So I just would understand Aggr function include the country that don't make the sales.

aggr 22_1.PNGaggr 22.PNG