# QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
Qlik Analytics Tour 2020 Online. Begins August 10th. Register Today
cancel
Showing results for
Did you mean:
Highlighted
Contributor III

## Set Analysis in AGGR Function

Hello Guys,

Just run out of ideas why the expression below still reacts to selections made in the [TRANSACTION TYPE] dimension;

SUM(AGGR(COUNT({\$<Year={'\$(vMaxYear)'},[TRANSACTION TYPE]=>}DISTINCT TransactionNumberToCount),[Transaction Number]))

Thanks.

1 Solution

Accepted Solutions
Highlighted
MVP

## Re: Set Analysis in AGGR Function

The additional scopes where you have to/can put set analysis are in bold below:

SUM( {} AGGR( {} COUNT({\$<Year={'\$(vMaxYear)'},[TRANSACTION TYPE]=>}DISTINCT TransactionNumberToCount),[Transaction Number]))

and in variable definition, may be like:

vMaxYear=Max( {} Year)

7 Replies
Highlighted
MVP

## Re: Set Analysis in AGGR Function

The additional scopes where you have to/can put set analysis are in bold below:

SUM( {} AGGR( {} COUNT({\$<Year={'\$(vMaxYear)'},[TRANSACTION TYPE]=>}DISTINCT TransactionNumberToCount),[Transaction Number]))

and in variable definition, may be like:

vMaxYear=Max( {} Year)

Highlighted
Contributor III

## Re: Set Analysis in AGGR Function

Thanks for that response, but then how would you combine them because your proposed expression seems incorrect.

Highlighted
MVP

## Re: Set Analysis in AGGR Function

How exactly you made the changes to your expression? Let me know what makes you think that it is incorrect. Try to share a sample app.

Highlighted
MVP

## Re: Set Analysis in AGGR Function

Just making it clear to what @tresesco  is trying to say

you may need to exclude the selection from your outer aggregation as well.

If you also don't want your vMaxYear to change for this selection, you may need to exclude the selection there as well

Assuming your variable expression is max(Year) then change it to max({<[TRANSACTION TYPE]=>}Year)

SUM({<[TRANSACTION TYPE]=>}AGGR(COUNT({\$<Year={'\$(vMaxYear)'},[TRANSACTION TYPE]=>}DISTINCT TransactionNumberToCount),[Transaction Number]))

Highlighted
MVP

## Re: Set Analysis in AGGR Function

@Kush , also possibly in aggr().

Highlighted
MVP

## Re: Set Analysis in AGGR Function

@tresesco  honestly I never used  excluding field set in aggr, but it works fine even though we did not write set there

Highlighted
MVP

## Re: Set Analysis in AGGR Function

@Kush , you are not wrong. However, there are cases when set analysis in aggr() is required, and since we don't know much deep about the requirement and business logic here it is good to go with the thumb rule (especially when one is not sure), i.e. - put set analysis in all possible aggregation functions and aggr() in the expression