Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
mikegrattan
Creator III
Creator III

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
Creator III
Creator III
Author

Thanks Vincent; I believe this will work.