Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
thanhphongle
Creator II
Creator II

not expression in if expression

This is my database

ProductStatus

Notebook

Broken

Notebook

Broken

Notebook

Broken

Notebook

Stolen
NotebookBorrowed
CellphoneBroken

Cellphone

Broken
CellphoneBroken
CellphoneSold
CellphoneIn used

I want QV to return in a Textbox

Broken Products = 6

Not Broken Products = 4

I used this as expression

if(Status='Broken', count(Product))

if(Status=<>'Broken', count(Product))

Unfortunetely it is not working. Is there a solution with if expression and set analysis?

12 Replies
sunny_talwar

I agree and if you need the set expression to be filtered based on selection in Status field. You can try these expressions:

1) Count({<Status *= {'Broken'}>}Product)

2) Count({<Status -= {'Broken'}>}Product)

thanhphongle
Creator II
Creator II
Author

My Set Analysis skills are not that good. But I'm still learning it. Thank you for your advices. I see my mistake with the if expression. I didnt expect that i have to use the count espression first and then the if expression. Thank you very much guys!

sunny_talwar

Basic set analysis is very easy and efficient way to restrict things. Lets go over the few expressions that I and others have used above.

1) Count({<Status = {'Broken'}>}Product)

Regardless of selection in Status, always show count of product where status = Broken.

2) Count({<Status *= {'Broken'}>}Product) -> Equailant of Count(If(Status = 'Broken', Product))

Show count of product where status is equal to Broken. But this is going to filter out any broken status if they are not part of the selection. So for instance if you select Sold in your example above, you will see 0 instead of 6.

3) Count({<Status ={'*'} - {'Broken'}>}Product)

Regardless of selection in status, always show couunt of products where status is not equal to broken

4) Count({<Status -= {'Broken'}>}Product) -> Equailant of Count(If(Status <> 'Broken', Product))

Show count of product where status is not equal to Broken. But this is going to filter out any non-broken status if they are not part of the selection. So for instance if you select Sold in your example above, you will see 1 instead of 4. If you select Broken, you will see 0.

I hope this will help clarify some of your set analysis doubts. For more information read the attached document. The document isn't perfect, but can help you learn a lot of things.