Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

If then else expression

I have a column, case type and two countries, Singapore and Malaysia.

I want to do a bar chart and have a count of case type for Singapore and Malaysia side by side.

The dimension is by months.

I'd like to use the if then else expression but I have no idea how to word it.

I want to do if country = singapore, then count (case type) if not, then do not count. How do I do that?

1 Solution

Accepted Solutions
tresesco
MVP
MVP

Try like:

Count({<Country={'Singapore'}>} [Case Type])                           // Set analysis; performance wise better

Or,

Count(If(Country='Singapore', [Case Type]) )                                // If ..then ..else

View solution in original post

4 Replies
tresesco
MVP
MVP

Try like:

Count({<Country={'Singapore'}>} [Case Type])                           // Set analysis; performance wise better

Or,

Count(If(Country='Singapore', [Case Type]) )                                // If ..then ..else

ashwanin
Specialist
Specialist

Below Expression provide you the count of CaseType where country=Singapore. Else it will not calculate.

=count({<Country={'Singapore'}>} CaseType)

PrashantSangle

Hi,

use set analysis Write two expression

like

count({<country={"Singapore"}>}case type)

and

count({<country={"Malaysia"}>}case type)

or if you want if else

then try like

count(if(country='Singapore',case type,if(country='Malaysia',case type)))

REgards

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Anonymous
Not applicable
Author

Hey Tresesco

how may I do the following expression in my chart?

- what I'm trying to do is - return only the results which are greater than or less than 3000 for example. for that i used

if(Sum({<Year=,Month]=, Date={'>=$(vYTDStart)<=$(vYTDEnd)'}>}Amount) >=3000 ,

Sum({<Year=,Month=, Date={'>=$(vYTDStart)<=$(vYTDEnd)'}>}Amount),'0')    // this is returning one end of the result. but then if i go

if(Sum({<Year=,Month]=, Date={'>=$(vYTDStart)<=$(vYTDEnd)'}>}Amount) >=3000 ,

Sum({<Year=,Month=, Date={'>=$(vYTDStart)<=$(vYTDEnd)'}>}Amount),'0')

or

if(Sum({<Year=,Month]=, Date={'>=$(vYTDStart)<=$(vYTDEnd)'}>}Amount) <= - 3000 ,

Sum({<Year=,Month=, Date={'>=$(vYTDStart)<=$(vYTDEnd)'}>}Amount),'0')  //this returns 0 or -1

if you could please point out what I'm doing that's incorrect.

Thanks.

Bon.