Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Calculated dimension in aggr

Hello,

is it possible to have aggr() do roll up over a calculated dimension? Something like:

=aggr(sum(Sales), Year(Date))

It looks like aggr breaks the moment I put any expression as dimension. For example,

this works: aggr(sum(Sales), Date)

and this doesn't: aggr(sum(Sales), if(1=1,Date))

Any help would be appreciated!

3 Replies
DavidFoster1
Specialist
Specialist

I dont think that would work as the aggr statement will not have something solid to query the data model with.

Does the calculated dimension have to be calculated on the front-end or could it be pushed back to the data model?

whiteline
Master II
Master II


Hi.

There is a note about calculated dimensions in help:

There is a special function for advanced aggregations:

aggr ([ distinct | nodistinct ]
[{set_expression}]expression {, dimension}
)

Returns a set of values of expression calculated
over dimensions. The result can be
compared to the expression column of a 'local chart', evaluated in the context
where the aggr function resides. Each dimension must be a single field. It cannot be an expression (calculated dimension).

...

Anonymous
Not applicable
Author

... That is, the field Year must be created in the script.  After that, this will work:

aggr(sum(Sales), Year)