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

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
karolina_
Creator II
Creator II

AGGR + Set analysis with the same DIM

Hi All,

I have a problem w AGGR with Set analysis the there is the same DIM in both

I want to compare in chart current year to previosu year and I have the expressions:

[This Year]

sum({<Year={$(=if(GetSelectedCount(Year)=1,Only(Year),vCurrentYear))}>} aggr(Count(DISTINCT

if([Date2]>=MonthStart and [Date2]<=MonthEnd, ID)

),ID, Year, Month, Date2))

[Year Ago]

sum({<Year={$(=if(GetSelectedCount(Year)=1,Only(Year),vCurrentYear)-1)}>} aggr(Count(DISTINCT

if([Date2]>=MonthStart and [Date2]<=MonthEnd, ID)

),ID, Year, Month, Date2))

This is working fine when no Year is selected.

When Year is selected (even the same as vCurrentYear) second expression [Year Ago] is not working.

I noticed that if I remove Year from AGGR Dimensions it is showing results whether Year is selected or not, however values are different with and without Year as AGGR Dim

sum({<Year={$(=if(GetSelectedCount(Year)=1,Only(Year),vCurrentYear)-1)}>} aggr(Count(DISTINCT

if([Date2]>=MonthStart and [Date2]<=MonthEnd, ID)

),ID, Month, Date2))


I have tried putting set analysis at different places but still they were not working

sum({SET ANALYSIS}  aggr ( count (
sum(aggr ( count ({SET ANALYSIS}
sum(aggr {SET ANALYSIS} ( count (    - I have QV 11.20 - this is underlined by QV as wrong, but it's giving results (different than other)


I have also tried with '1' instead of $ in set analysis.

Can anyone help how to keep Year in Set Analysis and AGGR DIM ?

Labels (1)
1 Solution

Accepted Solutions
tresB
Champion III
Champion III

In general the set component in aggr(), like

Aggr( {Set Analysis} Count(...

is equivalent to (unless you are using older version of qv than 12)

Aggr( Count ( <Set Analysis> ....

Have you tried the one I suggested? Isn't it working?

View solution in original post

5 Replies
tresB
Champion III
Champion III

What if you use set in aggr() like:

sum({SET ANALYSIS}  aggr (  {<Year>} count (


Edit: Of course, if your field is RoK, then the expression would be like: = sum({SET ANALYSIS}  aggr (  {<RoK>} count (


karolina_
Creator II
Creator II
Author

Almost
It is not working but this is:

sum({<Year={$(=if(GetSelectedCount(Year)=1,Only(Year),vCurrentYear)-1)}>} aggr(Count( {<Year>} DISTINCT

if([Date2]>=MonthStart and [Date2]<=MonthEnd, ID)

),ID, Year, Month, Date2))

(Can you edit your answer so i will mark it?)

Thanks a million!

karolina_
Creator II
Creator II
Author

Forgot to whole expression to english

Point is:
correct form is not sum({SET ANALYSIS}  aggr (  {<Year>} count (
but sum({SET ANALYSIS}  aggr (  count ( {<Year>}

which I would not try without your help, so I asked for edit your expression to mark it as vcorrect.

tresB
Champion III
Champion III

In general the set component in aggr(), like

Aggr( {Set Analysis} Count(...

is equivalent to (unless you are using older version of qv than 12)

Aggr( Count ( <Set Analysis> ....

Have you tried the one I suggested? Isn't it working?

karolina_
Creator II
Creator II
Author

I am using 11.20. Aggr( {Set Analysis} Count( - is marked as wrong in expression, but it is giving results. However not for previous year when Year is selected.

Only Aggr( Count ( <Set Analysis> .. gives results