Replace function

M.Lambert
M.Lambert Contributor
edited December 2023 in General

Hi there, I am trying to make a function to replace some values with null. I did it with on value but wanted to add more so I can clean more with one function. Can you help, please?

Best Answer

  • M.Lambert
    M.Lambert Contributor
    Answer ✓

    Hi Josh, thanks a lot for your help. That was spot on. Have a great day!

Answers

  • Josh Boxer
    Josh Boxer Administrator

    Hi, not entirely sure what you are trying to do, but it sounds like you are replace say 'blue' with null, but want to also replace 'green' and 'orange' with null?

    Firstly just checking but you need to create an advanced Function:

    either follow the link or create a standalone Function.

    Once you have done that there are quite a few different approaches. It is difficult to say which is best without more information on how many values you want to replace?, how similar those values are?, how frequently this list of values might change in future?

    Here is one idea:

    param test;
    IfThenElse(
      _Equals([p:test], {'blue', 'green', 'orange'}),
      null,
      [p:test]
    )