Switch Statement Formula


Adding a switch statement formula to Anaplan to get rid of long nested IFs!

This would assist in readability (and therefore maintenance) of complex formulae.

Switch statements allow you to test a condition, and assign an outcome to each condition.

For instance you may have want to test what mode of transport is being used: car, boat, or aeroplane.

Using an IF statement your formula may look like this:

IF Transport = Modes.Car THEN Car Outcome ELSE IF Transport = Modes.Boat THEN Boat Outcome ELSE IF Transport = Modes.Aeroplane THEN Aeroplane Outcome ELSE BLANK

The nested IFs cause Anaplan to check each condition in turn and doesn't represent the underlying logic of the calculation. You want one mode of transport to map to one condition, and not cycle through all conditions.

A switch could look like this:

SWITCH Transport CASE Modes.Car: Car Output CASE Modes.Boat: Boat Output CASE Modes.Aeroplane: Aeroplane Output CASE DEFAULT: BLANK

This also allows a model building to add a default, or exception, case.

11 votes

New · Last Updated


  • Could  you not have a module dimensioned on mode with outcome and just lookup against it?

    Potentially will also need to use FINDITEM if transport isn't formatted on Mode.

  • Status changed to: New
  • @Nicolas Cadier  I agree that the CASE statement could be more "readable" than "IF ELSE IF" statement...but I do not agree about the performance. 


    Using "IF ELSE IF" statements you could have the same result as a "CASE" statement that stops at the first "TRUE" condition.   


    In Anaplan the "IF ELSE IF" statement applies the "first true" exit and there is the possibility that not all the "IF's" in the statement are evaluated. 

    At the first TRUE "IF".. the calculation stops and the other "IF's" on that "ELSE" are not evaluated anymore. 


    This is why, as "best practice for performance" when using "IF ELSE IF" statements, is to put as early as possible the most probable TRUE "IF" statement in order to make Anaplan evaluate as less as possible from all the possibilities of an "IF ELSE IF" statements from a formula. 


    see below more information about this:



  • YES!

  • Another vote for this functionality.

Get Started with Idea Exchange

See our Submission Guidelines and Idea Evaluation Criteria, then start posting your own ideas and showing support for others!