Add Switch function to calculated field | Community
Skip to main content
ChrisStephens
New Participant
March 23, 2023
New

Add Switch function to calculated field

  • March 23, 2023
  • 4 replies
  • 1259 views

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 replies

Doug_Den_Hoed__AtAppStore
New Participant
March 23, 2023

 

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 

ChrisStephens
New Participant
March 23, 2023

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.

ChrisStephens
New Participant
March 23, 2023

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...

Doug_Den_Hoed__AtAppStore
New Participant
March 23, 2023

 

Hi @chrisstephens,

 

I invite you to Switch (#DadJokes) to the CASE keyword, and if that does the trick, please let me know.

 

Regards,

Doug