Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Aggr() expression?

Hi everyone.

I think I'm missing something with the aggr() function.

To explain it shortly, I want to compare the amount of sales done by each salesman in each country with the amount of sales done in each country by all salesmen. (by month, year and past 12 months).

I also wish that any selection (despite MonthYear) won't alter the result of the "€ Month (all Salesmen)" column.


In the app joined, I wish I could have the same values from "COUNTRY' pivot table

in the "€ Month (all Salesmen)" column of the "SALES by Country" pivot table.

Many thanks for any help provided.

David.

8 Replies
sunny_talwar

Isn't that what you already have? I am not sure what is missing here:

Capture.PNG

Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi David,

there is a very long explanation for the reasons why you don't need an AGGR() function in this case, and how to make it work properly. If you even make it to the Masters Summit for Qlik, you can listen to my 4-hour lecture that covers that, among other advanced AGGR() and Set Analysis issues. If you can't make it to the Masters Summit, you can read about it in my book QlikView Your Business.

The short version is this (you'll have to take my work for it though):

1. No need to use AGGR() - a simple sum(TOTAL<Country> Amount) with the same Set Analysis condition  will do the job.

2. You don't see exactly the same numbers because of your calculated Dimensions - if you clear the box "Suppress when Value is Null", you will see that some of the amounts are attributed to Country=NULL. That happens when one of your nested IF conditions (by the way, really-really bad for performance) render FALSE. I'd recommend to remove the IF conditions and achieve the same effect in a different way. I wasn't sure what exactly is it supposed to do...

cheers,

Oleg Troyansky

Upgrade your Qlik skills at the Masters Summit for Qlik - coming soon to Austin, Texas and Johannesburg, South Africa!

Not applicable
Author

Sorry, bad copy/paste.

Of course the values are here, but I wish them not to depend on any salesman man selection.

Not applicable
Author

Hi Oleg.

Wish I could join the summit but it won't be possible.

Plus, I don't think I have enough skills in both english and Qlik to attend it.

I know I can obtain these result without Aggr() but I don't see another way not to be dependant of any selection on the Salesman field.

Thanks.

Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi David,

once you use {1} in your Set Analysis , you disregard any selections. Alternatively, you can use the following to disregard just the selection of Salesman:

{$<Salesman=>}

AGGR() doesn't add any extra value in terms of disregarding the selection of a Salesman.

Not applicable
Author

Hi Oleg.

Ok I think I'm trying to achieve something not possible the way I tried it or I haven't been clear enough sorry.

So let's ask the question differently,

From the beginning :

    1) I want to compare, for a selected MonthYear, the amount of sales done by each salesman in each country with the amount of sales done in each country by all salesmen. (by month, year and past 12 months).

    2) also, that any selection (despite MonthYear) won't alter the result of the "€ Month (all Salesmen)" column.

    3) and, to hide other Salesmen rows when one (or more) is selected.

So this is the pivot table (with no calculated dimensions) :

Two dimensions : Salesman, Country    

Three Expressions :

     - € Month          : =sum({<MonthYear={'$(=Only(MonthYear))'}>} Amount)

     - € Month (AllS) : =sum(TOTAL <Country> {$<Salesman=, MonthYear={'$(=Only(MonthYear))'}>} Amount)

     - AGGR : =sum(TOTAL <Country> {1<MonthYear={'$(=Only(MonthYear))'}>} aggr(sum(TOTAL <Country> {1<MonthYear={'$(=Only(MonthYear))'}>} Amount), Country))

Wanted.PNG

At that point I wish to keep these expression values despite dimensions are reduced or not like here :

problem_1.PNG

And, if a salesman is selected, to hide the other ones :

problem_2.PNG

Is this even possible?

Thanks.

Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Yes, it's certainly possible. I just don't have as much time to delve into all the details of this calculation.

I think you can find some hints to the solution in this blog article:

http://www.naturalsynergies.com/q-tip-8-ranking-the-unrankable/

cheers,

Oleg Troyansky

raju_insights
Partner - Creator III
Partner - Creator III

Hi DAVID MALAIZIER,

I have aggregated the amount -> country and month year wise to get what you asked. What I am providing is an idea for your requirement. See the script. Hope this helps

PFA.