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

Suggest Alternative to an If Statement

I understand that If Statements are big no nos in Qlikview.

I have a decent understanding of Set Analysis. My current requirement is to only calculate a value when a single value is selected for the the Store.

=if(GetSelectedCount(Store)=1,'Dogs:'&Count({$<PetType={'Dog'}>} Distinct PetID),'Select a Store')

I am sure this has been answered a few times, please feel free to direct me to an answer. I searched a few ways. I have seen a solution that uses pick match, but I am not sure if that solution applies in this situation.

Thanks in advance

1 Solution

Accepted Solutions
sunny_talwar

Here is Pick() way to do this

=Pick((GetSelectedCount(Store)=1)+2,'Dogs:'&Count({$<PetType={'Dog'}>} Distinct PetID),'Select a Store')

View solution in original post

7 Replies
vishsaggi
Champion III
Champion III

What are you expecting to see in your text boxes?

datagrrl
Creator III
Creator III
Author

I am expecting to see what is there.

I am being told if statements are an absolute no and can not be used due to performance issues. I am just wondering what the alternatives are.

sunny_talwar

Here is Pick() way to do this

=Pick((GetSelectedCount(Store)=1)+2,'Dogs:'&Count({$<PetType={'Dog'}>} Distinct PetID),'Select a Store')

sunny_talwar

Your sample file attached

Capture.PNG

sergio0592
Specialist III
Specialist III

Try with :

=pick(match(GetSelectedCount(Store),1)+1,'Dogs:'&Count({$<PetType={'Dog'}>} Distinct PetID),'Select a Store')

datagrrl
Creator III
Creator III
Author

Thanks

I was making this a lot harder than it needed to be. I will see if this works in my application and mark this as the correct answer if so. Thanks again.

adityadey123
Partner - Contributor
Partner - Contributor

Hi, could you tell me if using this method across my application will improve the performance?