cancel
Showing results for 
Search instead for 
Did you mean: 

How to use character comparaison with IF condition in Formula Mode?

SylvainA
Deputy Chef I
Deputy Chef I

Hello everyone,

With Automation studio, I need to do a character comparaison in Formula Mode.  My currency code in Epicor is CAN but I need to save CAD in currency code of HudSpot.

I need to do something like this:

CurrencyCodeField = "CAN"? "CAD" : "USD"

I tried this but it doesn't work.  

1 ACCEPTED SOLUTION

shivakumara
Executive Chef II
Executive Chef II

Hi @SylvainA ,
Here is solution:

If condition check.PNG
I prefer to add one more condition to have optimize solution to avoid the wrong response
<Input> == "CAN" : "CAD" : <input> == "USD" ? "USD" : "Wrong Input"
More optimized if.PNG

Thanks and Regards,
Shivakumar K A

View solution in original post

7 REPLIES 7

Prudvi
Deputy Chef III
Deputy Chef III

Hi @SylvainA,
Did you try using "match?" formula.(MatchFunction )

datapill.match?(/CAN/)?"CAD":"USD"

I have created a variable and using match function, I am validating if the variable contains the CAN.
If true passes CAD and false passes USD.
Regards,
Prudvi

 

Hi @Prudvi,

Your solution not works in most cases, Say if the word is prefixed or suffixed with "CAN," it still returns "CAD."

For exmmple:
- "DECCAN" matches and results in "CAD."
- "CANBERRY" also returns "CAD."

While I understand that we are aiming for accurate input matching, our solution should be more optimized to handle such cases effectively.

Thanks and Regards,
Shivakumar K A

Hi @shivakumara,
Thanks for pointing out.
Regards,
Prudvi

shivakumara
Executive Chef II
Executive Chef II

Hi @SylvainA ,
Here is solution:

If condition check.PNG
I prefer to add one more condition to have optimize solution to avoid the wrong response
<Input> == "CAN" : "CAD" : <input> == "USD" ? "USD" : "Wrong Input"
More optimized if.PNG

Thanks and Regards,
Shivakumar K A