Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
datashaw
Contributor III
Contributor III

If condition within Set Analysis expression

Can you please help to me to write the below if condition inside the set analysis please

Set Analysis Expression =

Count({< STATUS ={'Rejected'}, TYPE ={'RTP'}>}  Items)

IF Condition:

=if( Switcher = Payer,  Switcher ,null()).

on above if Condition all are column names

Basically I want to show this on the KPI in Qlik Sense.

I appreciate if you could help me to resolve the issue.

 

 

Labels (1)
2 Solutions

Accepted Solutions
Lauri
Specialist
Specialist

You can't write IF inside of set analysis, only outside:

If(Switcher=Payer, Count({<STATUS ={'Rejected'}, TYPE ={'RTP'}>}  Items))

View solution in original post

datashaw
Contributor III
Contributor III
Author

I found the answer... Thanks for the help 🙂

Count({<STATUS ={'Rejected'}, TYPE ={'RTP'}>} If(Switcher=Payer, Items))

View solution in original post

8 Replies
Lauri
Specialist
Specialist

Are you using IndirectPayer as a dimension in your KPI? Or are you limiting the Items that get counted?

datashaw
Contributor III
Contributor III
Author

This is just a KPI  numbers on the dashboard there no Dimension. 

 

*Just limiting the items to get counted

Please correct my set analysis part with if condition 

Count({<       '*IF condition here'  ,             STATUS ={'Rejected'}, TYPE ={'RTP'}>}  Items)

=if( Switcher = Payer,  Switcher ) 

 

 

Field names:

Switcher = Santander, Barclays, City, Lloyds, HSBC...etc 

Payer = HSBC, Habib, Natwest, City, TSB, Santander.... etc,

Lauri
Specialist
Specialist

You can't write IF inside of set analysis, only outside:

If(Switcher=Payer, Count({<STATUS ={'Rejected'}, TYPE ={'RTP'}>}  Items))

datashaw
Contributor III
Contributor III
Author

Thanks for the reply Laurischarf, I would expect the result would be 3-5 digit Number, but it does not show anything just an '-' on the KPI
datashaw
Contributor III
Contributor III
Author

I found the answer... Thanks for the help 🙂

Count({<STATUS ={'Rejected'}, TYPE ={'RTP'}>} If(Switcher=Payer, Items))
Lauri
Specialist
Specialist

Of course! Sorry for my error. Glad you figured it out.
datashaw
Contributor III
Contributor III
Author

But in the if statement how do i avoid nulls
is that something like this..? please correct

Count({<STATUS ={'Rejected'}, TYPE ={'RTP'}>} If(Switcher=Payer -= "=Null()" , Items))
Lauri
Specialist
Specialist

No, you have to put all set analysis statements between { }. Are you getting Items where Switcher and Payer are Null? I would expect the If statement to remove them, because Qlik doesn't consider Null a value, so when Switcher and Payer are Null, they are not equal. They are nothing.

Still, you can make sure to get only values using a wildcard, like this:

Count({<STATUS ={'Rejected'}, TYPE ={'RTP'}, Switcher={'*'}>} If(Switcher=Payer, Items))

Or do it in the If, but they say performance is better with set analysis.

Count({<STATUS ={'Rejected'}, TYPE ={'RTP'}>} If(Switcher=Payer and Len(Switcher)>0, Items))