none
switch statement in Indicator field RRS feed

  • Question

  • Switch(([Baseline Cost] - [Actual Cost])/[Baseline Cost] *100 >, "1",
     ([Baseline Cost]  - [Actual Cost])/[Baseline Cost] *100 >10 and ([Baseline Cost]  - [Actual Cost])/[Baseline Cost] *100 <20,"2"))

    I have set indicator 1 as green and 2 as red nothing working


    Regards, Syed Faizan ur Rehman, CBPM®,PRINCE2®, MCTS

    Monday, December 15, 2014 7:24 AM

Answers

  • Thus this should work:

    Switch(

    ( [Baseline Cost] - [Actual Cost] ) / [Baseline Cost]  * 100  < 20 , 1,

    ( [Baseline Cost] - [Actual Cost] ) / [Baseline Cost]  * 100  > 10 , 2,

    True, 3

    )


    Hope this helps,


    Guillaume Rouyre, MBA, MVP, P-Seller |

    Tuesday, December 16, 2014 1:30 PM
    Moderator

All replies

  • Hi Syed,

    If you remove the indicators, does it display 1, 2 etc?

    Also, which version of Project/Project Server are you using, and are you viewing this in Project Server  or PWA?   If PWA, does it work in Project?  If it works in Project, have you published the file?


    Ben Howard [MVP] | web | blog | book | P2O

    Monday, December 15, 2014 8:34 AM
    Moderator
  • I am working with Project Server 2013.

    Regards, Syed Faizan ur Rehman, CBPM®,PRINCE2®, MCTS

    Monday, December 15, 2014 9:22 AM
  • As Ben suggested, does the formula returns 1 or 2 if you remove the graphical indicator?

    That being said, maybe it is a typo but I can see that a condition is missing after the fiest ">". 


    Hope this helps,


    Guillaume Rouyre, MBA, MVP, P-Seller |

    Monday, December 15, 2014 1:18 PM
    Moderator
  • In addition to this, there is an extra ")" at the end. Assuming your calculation is the following in number1:

    ([Baseline Cost] - [Actual Cost])/[Baseline Cost] *100

    Your formula should be:

    Switch([Number1]>20;"1";[Number1]>10 And [Number1]<20;"2")
    Note that with my regional settings, I replaced "," by ";". I also extrapolated your first condition being more that 20. Then I tried the graphical indicator and it worked with the formula above.


    Hope this helps,


    Guillaume Rouyre, MBA, MVP, P-Seller |

    Monday, December 15, 2014 1:26 PM
    Moderator
  • Switch(

    ( [Baseline Cost] - [Actual Cost] ) / [Baseline Cost]  * 100  > ????, "1",

    ( [Baseline Cost]  - [Actual Cost]) / [Baseline Cost]  * 100  > 10 AND

    ( [Baseline Cost]  - [Actual Cost]) / [Baseline Cost]  * 100  < 20, "2")

    , True, ????

    )

    Try:

    Switch(

    ( [Baseline Cost] - [Actual Cost] ) / [Baseline Cost]  * 100  < 10, 1,

    ( [Baseline Cost] - [Actual Cost] ) / [Baseline Cost]  * 100  >= 10 AND

    ( [Baseline Cost] - [Actual Cost] ) / [Baseline Cost]  * 100  <= 20, 2,

    True, 3

    )

    9 will return 1; 10, 15, 20 will return 2 and all values greater than 20 will return 3. No need to return values as strings.





    Monday, December 15, 2014 3:13 PM
  • My formula is 

    Switch(([Baseline Cost] - [Actual Cost]) / [Baseline Cost] * 100 > 20, "1", ([Baseline Cost] - [Actual Cost]) / [Baseline Cost] * 100 > 10, "2", True, 3)

    1=Green

    2= Red

    3= Orange


    Regards, Syed Faizan ur Rehman, CBPM®,PRINCE2®, MCTS

    Tuesday, December 16, 2014 1:27 PM
  • Thus this should work:

    Switch(

    ( [Baseline Cost] - [Actual Cost] ) / [Baseline Cost]  * 100  < 20 , 1,

    ( [Baseline Cost] - [Actual Cost] ) / [Baseline Cost]  * 100  > 10 , 2,

    True, 3

    )


    Hope this helps,


    Guillaume Rouyre, MBA, MVP, P-Seller |

    Tuesday, December 16, 2014 1:30 PM
    Moderator