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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Help with simple expression: if then statement

Somewhat new to qlikview and I need to create a simple expression, saying that if a certain criteria is met (in this case, CountryName = 'USA'), then I want to count the distinct number of shipments coming out of that country.

I tried the following but it's not working:

=IF(CountryName = 'USA'),COUNT(DISTINCT(SHIPMENTS))

I want to make sure that the count I get is only for shipments coming out of the USA, not all shipments from all countries.  What is the proper expression?

Thanks!

1 Solution

Accepted Solutions
sunny_talwar

May be try one of these:

=If(CountryName = 'USA', Count(DISTINCT SHIPMENTS))

or

=Count(DISTINCT {<CountryName = {'USA'}>} SHIPMENTS)

View solution in original post

3 Replies
sunny_talwar

May be try one of these:

=If(CountryName = 'USA', Count(DISTINCT SHIPMENTS))

or

=Count(DISTINCT {<CountryName = {'USA'}>} SHIPMENTS)

Not applicable
Author

The second option worked.  Thank you!

=Count(DISTINCT {<CountryName = {'USA'}>} SHIPMENTS)

sunny_talwar

Then the if alternative of the set analysis is this:

=Count(DISTINCT If(CountryName = 'USA', SHIPMENTS))