Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
mikegrattan
Specialist
Specialist

Help with aggr in pivot table - need to get the overall average by year

I have the following expression  in a pivot table measure:

aggr( count(distinct WorkDate),WorkMonth,WorkYear,BusUnit)

It works at the WorkMonth level but I would like to get the average as a total for the year.  Please advise...thank you.

mikegrattan_0-1695655647039.png

 

Labels (1)
1 Solution

Accepted Solutions
vincent_ardiet_
Specialist
Specialist

You can use dimensionality() function to change the behaviour of your expression based on the level of aggregation you are.
For example:
If(Dimensionality()=2
    ,aggr( count(distinct WorkDate),WorkMonth,WorkYear,BusUnit)
    ,aggr(avg(aggr( count(distinct WorkDate),WorkMonth,WorkYear,BusUnit)),WorkYear,BusUnit))


 

View solution in original post

2 Replies
vincent_ardiet_
Specialist
Specialist

You can use dimensionality() function to change the behaviour of your expression based on the level of aggregation you are.
For example:
If(Dimensionality()=2
    ,aggr( count(distinct WorkDate),WorkMonth,WorkYear,BusUnit)
    ,aggr(avg(aggr( count(distinct WorkDate),WorkMonth,WorkYear,BusUnit)),WorkYear,BusUnit))


 

mikegrattan
Specialist
Specialist
Author

Thanks Vincent; I believe this will work.