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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
gandalfgray
Specialist II
Specialist II

if in set expressions

I want to use set analysis to make selections in one field ("ActualField") using another field ("SelectorField").

so this does the trick, right:

Count({<ActualField=SelectorField>} DISTINCT ID)

But not completely,

This works as expected for all cases, except when there is no selection made in SelectorField,

when the above does not return a value.

I found a solution for that:

if(GetSelectedCount(SelectorField)>0,

    Count({<ActualField=SelectorField>} DISTINCT ID),

    Count({<ActualField=} DISTINCT ID)

)

But is there a syntax to get the "if" inside the set expression,

I tried like this but it does not work:

Count({$<ActualField={$(=if(getselectedcount(SelectorField)>0,SelectorField,ActualField))}>} DISTINCT ID))

1 Solution

Accepted Solutions
erichshiino
Partner - Master
Partner - Master

Try this:

Count({<ActualField=p(SelectorField)>} DISTINCT ID)

This should get all possible values in SelectorField and use as values for ActualField

Hope it helps,

Erich

View solution in original post

3 Replies
erichshiino
Partner - Master
Partner - Master

Try this:

Count({<ActualField=p(SelectorField)>} DISTINCT ID)

This should get all possible values in SelectorField and use as values for ActualField

Hope it helps,

Erich

gandalfgray
Specialist II
Specialist II
Author

Excellent Erich!

I knew there was an elegant way to solve this.

Thanks!

perumal_41
Partner - Specialist II
Partner - Specialist II

please explain breifly .

Count({<ActualField=p(SelectorField)>} DISTINCT ID)