Expand my Community achievements bar.

The Community Advisors application is now OPEN for the second class of 2024. Apply to become a part of this exclusive program!

Add Switch function to calculated field

Avatar

Community Advisor

3/23/23

Description - I would like the switch function to be added as a useable function inside of a calculated field.

Why is this feature important to you - It would make coding calculated fields much easier in some circumstances.

How would you like the feature to work - Just like a switch command, where you tell it which variable(s) to pull in and then you can say if variable = A, calculation = 1, if variable = B, calculation = 2, etc.

Current Behaviour - The behavior can be achieved currently, but it requires the use of many nested IF statements, which is rather unwieldy in trying to write.

4 Comments

Avatar

Community Advisor

3/23/23

Thanks for the suggestion, Doug. Let me take a look at it.

 

If this works I will both be ecstatic and so angry at the same time...

Avatar

Community Advisor

3/23/23

Unless I'm misunderstanding how CASE works, I'm not sure that would work. As an example, this:

 

Field value: Spanish, LA

Calculation 1: es-LA

Calculation 2: LA-es

Calculation 3: Spanish, LATAM

 

While this example is made up, it's not too far from what I'm working right now, because I am integrating with multiple different systems, and a single selected value could need to be represented in several different ways, depending on which system the field links with.

 

Edit: Ah wait, now that I read my question I can see why you thought the CASE function would work, bad example on my part.

Avatar

3/23/23

 

No worries @ChrisStephens, and perhaps still an alternative...

 

I wonder if the IFIN function on the same article be a better fit:

 

IFIN(value, value1, value2,..., trueExpression, falseExpression)

such as

IFIN({DE:Variable}, "A", "B", "C", CONCAT("calculation 1"), IFIN({DE:Variable}, "D", "E", "F", CONCAT("calculation 2"), CONCAT("calculation 3")))

Regards,

Doug