Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
jessica_webb
Creator III
Creator III

Nested if statement within set analysis

Hello,

I have a chart expression using set analysis, part of which is as follows:

Phase={'$(vPhase)'}

The variable 'vPhase' is changed when the user selects a button - Early, Late, All

The problem is, whilst 'Early' and 'Late' are values in field 'Phase' (so expression works fine for those two), 'All' is not a value in 'Phase' - it's just all values!

I was thinking I would replace the above part of my set analysis to include an if statement, but can't get it working. So far, I have:

Phase={'$(=IF(vPhase='Early','Early',IF(vPhase='Late','Late',IF(vPhase='All','???')))'}



But, I'm not sure if I'm declaring my variables correctly here - never sure when they should/shouldn't be bracketed - and I also don't know what I want to say for the 'then' part of my 'If' statement for 'All'. Can I say  IF(vPhase='All','Early' and 'Late) ?

19 Replies
sunny_talwar

I think you accidentally marked your own response as helpful when you might be wanting to mark Tamil's response as helpful

sunny_talwar

I think the red squiggly can be avoided by using double quotes around the expression:

Phase={"$(=If(vPhase ='Early','Early',If(vPhase='Late','Late','*')))"}

tamilarasu
Champion
Champion

You are right Sunny. I thought of editing my post but you have already suggested a good solution. So I just left it, as it is. BTW, I really don't bother about the points. Rather, I am very much concerned, if my solution helped them in someway.

jessica_webb
Creator III
Creator III
Author

Haha, thank you!

I got my  email notification and thought "that's nice, but I don't really understand what I said that was helpful.."

Oh dear, Friday fatigue!

sunny_talwar

Good

But my suggestion was not to get points to you my friend. These responses are going to be used by others in the future and I would want them to look at responses which were helpful. In this case Jessica mentioned that your response was helpful, so other should see them as well.

Best,

Sunny

Anonymous
Not applicable

Hi Jessica, I didn't know all expression was written.

Other option  than Sunny solution is modify vPhase value on button, on All button, or when option is All, write on variable *.

Regards!

jessica_webb
Creator III
Creator III
Author

Hi Manuel,

Another really good suggestion, thank you.

Best wishes,

Jess

Anonymous
Not applicable

You're wellcome!

kmstephenson
Creator
Creator

Does this functionality not work in newer versions of QlikView 12? I used this syntax successfully in an older version of the tool but just noticed that it is not resolving correctly anymore. Only thing I can think of was upgrade to newer release of QlikView.

sunny_talwar

There might have been some changes in the most recent version of QlikView.... check here:

Quotes in Set Analysis