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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Janneke
Creator
Creator

Set analysis needed in field aggr-function?

Hi all,

I'm running into a problem using the aggr-function in combination with set analysis. There are a number of selections possible, including YEAR. However, selection of a YEAR should not affect the outcome.

This is the expression I am using:

=aggr(NODISTINCT count({$<YEAR=>}ID),YEAR)

This is the outcome (selected YEAR is 2013):

GROUP     YEAR          #

A         2013          100

A         2014          -

B         2013          100

B         2014          -

This is what I would like to have (selected YEAR is 2013):

GROUP     YEAR          #

A         2013          100

A         2014          200

B         2013          100

B         2014          200

The expression is basically working, however it works only for the chosen YEAR. I think this has to do with the aggr-field YEAR that I use (without set analysis).

Could someone please help me? Thanks in advance!!

Regards, Janneke.

1 Solution

Accepted Solutions
danielact
Partner - Creator III
Partner - Creator III

Try putting an Only({$<YEAR=>} around your aggr function.

View solution in original post

5 Replies
MK_QSL
MVP
MVP

COUNT({<YEAR = >}ID)

Janneke
Creator
Creator
Author

Hi Manish,

This gives the wrong amount, I think because GROUP and ID are from different tables.

Greetings, Janneke.

anbu1984
Master III
Master III

Can you post sample qvw

danielact
Partner - Creator III
Partner - Creator III

Try putting an Only({$<YEAR=>} around your aggr function.

Janneke
Creator
Creator
Author

Thank you Daniel!!

=only({$<YEAR=>}aggr(NODISTINCT count({$<YEAR=>}ID),YEAR))

works perfectly.

Regards, Janneke.