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

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to exclude the filter if it is none selected in Set Analysis?

For example,

when selection: Year_C(2009,2010) --- one or more value is selected,

Month_C(1,2,3,4,5,6,7,8,9,10,11,12) --- one or more value is selected

Year_V(2009,2010) --- one or more value is selected,

Month_V(1,2,3,4,5,6,7,8,9,10,11,12) --- one or more value is selected

then the Set Analysis expression is:

sum({<Year=Year_C,Month=Month_C>} sales) - sum({<Year=Year_V,Month=Month_V>} sales)

but if when Month_C and Month_V is none selected,

then I want the expression will be:

sum({<Year=Year_C>} sales) - sum({<Year=Year_V>} sales) (Month is excluded)

How to write a simply expression to achieve it?

4 Replies
pover
Partner - Master
Partner - Master

You could do the following:

=if(GetSelectedCount(Month_C)=0 or GetSelectedCount(Month_V)=0,

'sum basado en año',

'sum basado en año y mes'

)

Regards.

Anonymous
Not applicable
Author

Can I use IF in Set Analysis?

pover
Partner - Master
Partner - Master

No, you cannot put an if in set analysis.

The syntax would be:

if( condition, sum({$<...>} amount), sum({$<...>} amount))

In many cases, your's included, it might be easier to do a sum( if(year=year_c, amount,0) instead of sum({$<year=year_c>} amount) because I don't think set analysis is going to work when you have more than one year_c selected.

Regards.

Not applicable
Author

Hi Karl,

I have similar expression, but what i'm trying to do is, to exclude zone ,

i can easily do it in SET, but how do i do it with the IF?

any idea?

if( condition, sum({$<zone=>} amount), sum({$<zone=>} amount))

THanks.