Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
BrunPierre
Master
Master

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
tresesco
MVP
MVP

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)

View solution in original post

7 Replies
tresesco
MVP
MVP

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)

BrunPierre
Master
Master
Author

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

 

 

tresesco
MVP
MVP

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.

Kushal_Chawda

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]))

tresesco
MVP
MVP

@Kushal_Chawda , also possibly in aggr().

Kushal_Chawda

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

tresesco
MVP
MVP

@Kushal_Chawda , 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