Regarding ifelse command

Suppose my algo versions are following:
Simple 1.5_23
Simple 1.5_12
Simple 1.5_42
Simple 1.5_62
Simple 1.0_44
Simple 1.0_56
Simple 1.0_22
Simple 1.0_67
Simple 2.0_81
Simple 2.0_92

And I am writing the below if else query

ifelse( {algo_version}= ‘Simple 1.5_23’ OR {algo_version}= ‘Simple 1.5_62’ OR {algo_version}= ‘Simple 1.5_42’ OR {algo_version}= ‘Simple 1.5_12’, {Imbalance Revenue Monthly Simulation}, NULL)

Now I want the above ‘ifelse’ command to select just the algorithm version starting from ‘Simple1.5_XX’ not other algo version(Simple1.0_XX; Simple2.0_XX).
Is there any other way to write the above query instead of writing each and every algo version starting with ‘Simple1.5_XX’ ?

Hi @Dhiru,
You could try using the contains() function to support this. Then you could just use the number that follows Simple…For example: contains(‘1.5’) and repeat for each ‘1.0’, ‘2.0’, etc.

Let me know if that works for your case.

Thank you!

Hey Brett,
Thank you for the quick response. I have tried to use the Contains as shown below in images. Seems there are syntax errors. In what format should we write the query?


Hi @Dhiru,
Sorry for the confusion on my part, the contains function cannot be nested in an ifelse statement.
Just to confirm again, what output are you looking to achieve from this formula? So, once you have it narrowed down to algo version, what would you then be using that to accomplish?

Thank you!

ifelse( {algo_version}= ‘Simple 1.5_23’ OR {algo_version}= ‘Simple 1.5_62’ OR {algo_version}= ‘Simple 1.5_42’ OR {algo_version}= ‘Simple 1.5_12’, {Imbalance Revenue Monthly Simulation}, NULL)

This is the IFELSE formula I am currently using, and it provides the correct output by selecting the specific algo versions I have specified. However, instead of updating the formula each time when there is a new algo version starting with ‘Simple1.5_XX,’ I am considering using the CONTAINS function, as you suggested. I am not certain how to implement it.

Hi @Dhiru,
Ok, contains function should work for this instance then, let’s try something like the following:

ifelse(contains({algo_version}, '1.5', CASE_INSENSITIVE), {Imbalance Revenue Monthly Simulation}, NULL)

Hey Brett,
The above formula worked.
Thank you

1 Like