Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Modernize Your QlikView Deployment webinar, Nov. 3rd. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
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) ?

1 Solution

Accepted Solutions
Highlighted

How about this:

Phase={"$(=Pick(Match(vPhase, 'Early', 'Late', 'All'), 'Early', 'Late', '*'))"}

View solution in original post

19 Replies
Highlighted
Master II
Master II

May be as below:

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



Highlighted
Specialist III
Specialist III

Hi Jessica,

Try this:

     If(vPhase = 'All',

          Use this set analysis: Phase={'*'},

          Phase={'$(vPhase)'}

     )



​Regards!!

Highlighted
Creator III
Creator III

Hi,

Unfortunately that doesn't seem to work - I just get the red 'error' line under that part.

Highlighted
Specialist II
Specialist II

Could you share a sample of your application

Highlighted
Creator III
Creator III

Hi Manuel,

I don't understand how that would fit into my overall expression.

In its entirety it reads:

=IF (Name='$(vName)', COUNT ({1<Overall ={4},Phase={'$(vPhase)'}, [Date set]={1} >}

DISTINCT ID)/COUNT (

{1<Overall={1,2,3,4}, Phase={'$(vPhase)'}, [Date set]={1} >}

DISTINCT ID),

COUNT (TOTAL {1<Overall={4},Phase={'$(vPhase)'}, [Date set]={1} >}

DISTINCT ID)/COUNT ( TOTAL

{1<Overall={1,2,3,4}, Phase={'$(vPhase)'}, [Date set]={1} >}

DISTINCT ID))

How would I add the new If statement in place of the bolded parts?

Thanks,

Jess

Highlighted

How about this:

Phase={"$(=Pick(Match(vPhase, 'Early', 'Late', 'All'), 'Early', 'Late', '*'))"}

View solution in original post

Highlighted
Creator III
Creator III

Absolutely perfect!

Thank you so much (for the hundredth time this week!).

Best wishes,

Jess

Highlighted

Sunny has already suggested a best solution. Just thought to share suing If method.

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

Ignore the red squiggly lines.

Highlighted
Creator III
Creator III

Hi Tamil,

Thank you - that's really useful!

One of the issues I was having was declaring my variables properly, so this will be a big help for next time!

Thanks again,

Jess