Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
rutger_jansen
Contributor III
Contributor III

Aggr() with drill down

Hi,

Please find attached some sample data; I'm struggling to get the syntax right for this aggr() expression.

Intention is to sum Time in each stage per Name and show the average of time in stage at higher levels of aggregation (in real world there are multiple hierarchical levels and some set analysis, in the example just 'TEAM'). Currently I have:


Avg( Aggr( Sum(Time), Stage, $(=GetCurrentField([Hierarchy])) ) )

The desired result:

TEAMABC
X23.585
Y6102

and (drilling down from X):

NameABC
Bill3094
Harry1776

Any help would be great,

Thanks,

Rutger

1 Solution

Accepted Solutions
sunny_talwar

Try this

Avg( Aggr( Sum(Time), Stage, $(=GetCurrentField([Hierarchy])) ) )/Count(DISTINCT Name)

View solution in original post

4 Replies
sunny_talwar

Try this

Avg( Aggr( Sum(Time), Stage, $(=GetCurrentField([Hierarchy])) ) )/Count(DISTINCT Name)

swuehl
MVP
MVP

Maybe your real word problem is more complex, but it should also be sufficient to use

Avg( Aggr( Sum(Time), Stage, TEAM,Name ) )

edit:

Or even

Avg( Aggr( Sum(Time), Stage, Name ) )

rutger_jansen
Contributor III
Contributor III
Author

Thanks very much Sunny! (I had to remove the inner '=' for it to work in the real example but yours worked in the sample)

rutger_jansen
Contributor III
Contributor III
Author

Thanks Stefan, much appreciated. I prefer this answer because I didn't really understand why the avg() needed to be divided by a count (though it worked!?).