Skip to main content
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) ?

1 Solution

Accepted Solutions
sunny_talwar

How about this:

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

View solution in original post

19 Replies
trdandamudi
Master II
Master II

May be as below:

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



Anonymous
Not applicable

Hi Jessica,

Try this:

     If(vPhase = 'All',

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

          Phase={'$(vPhase)'}

     )



​Regards!!

jessica_webb
Creator III
Creator III
Author

Hi,

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

anushree1
Specialist II
Specialist II

Could you share a sample of your application

jessica_webb
Creator III
Creator III
Author

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

sunny_talwar

How about this:

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

jessica_webb
Creator III
Creator III
Author

Absolutely perfect!

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

Best wishes,

Jess

tamilarasu
Champion
Champion

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.

jessica_webb
Creator III
Creator III
Author

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