Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
BarryPollock
Contributor III
Contributor III

How to count items if there is a condition?

I want to create a bullet gauge the shows what portion of systems are connected.  The CONNECTIVITY field is populated with 'Yes' or 'No'.

I managed to do this by creating an additional field called CONNECT_NUMERIC and populated it with 1's and 0's by putting in this expression:  =if(CONNECTIVITY ='Yes', 1, 0)

In the bullet gauge, my expression is Sum(Connect_Numeric) and I set my max range expression to Count(Connect_Numeric)

This process seems cumbersome.  Is there a way to do this without adding additional fields?  I'd like to write the expressions directly into the gauge options.  I'd also like to be able to do this with multiple conditions.


So consider CONNECTIVITY = 'Yes' and ACTIVE_SYSTEM = 'Yes'

I'd like to do something like the following:

Gauge Data Measures:

Count if CONNECTIVITY = 'Yes' AND if ACTIVE_SYSTEM = 'Yes'

Gauge Presentation Max Range Limit:

Count if ACTIVE_SYSTEM ' 'Yes'


Thanks!







1 Solution

Accepted Solutions
BarryPollock
Contributor III
Contributor III
Author

So the AND function was  much simpler than I expected.

Expression:
=sum(if(CONNECTIVITY = 'Yes' and ACTIVE_SYSTEMS = 'Yes', 1, 0))

Max Range:
=sum(if(ACTIVE_SYSTEMS = 'Yes', 1, 0))

View solution in original post

2 Replies
BarryPollock
Contributor III
Contributor III
Author

Okay, it looks like the following expression gets me half the way there:

Gauge Data Measures:

=sum(if(Connectivity = 'Yes',1,0))

Gauge Presentation Max Range Limit:

= count (Connectivity)



Now I need to figure out how to use an AND so that I can modify my first statement.

BarryPollock
Contributor III
Contributor III
Author

So the AND function was  much simpler than I expected.

Expression:
=sum(if(CONNECTIVITY = 'Yes' and ACTIVE_SYSTEMS = 'Yes', 1, 0))

Max Range:
=sum(if(ACTIVE_SYSTEMS = 'Yes', 1, 0))