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: 
Not applicable

Problem when using if statement and count in same expression

Good Morning,

I need to use if statement and count in same expression.  When using the following expression i'm getting no data.

=If(Identity = 'A', count(distinct{<Identity = {'A'}>}[ID]), If (Identity = 'B',count(distinct{<Identity = {'B'}>}[ID])))

2 Replies
Not applicable
Author

the syntax is := count (if(condition,value))

Not applicable
Author

Try putting the distinct after the set expression:

=If(Identity = 'A' , count({<Identity = {'A'}>}distinct [ID]),

If (Identity = 'B' , count({<Identity = {'B'}>}distinct [ID])))

Or you can create 2 expressions

A:

count({<Identity = {'A'}>}distinct [ID])

B:

count({<Identity = {'B'}>}distinct [ID])