Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
10 years ago
Solved

substitute multiple values

Hi I would like to substistute multiple values with one value,

 

In Excel it can be done by =Substitute(Cell reference,{"Trust","Foundation","Endownment"},"") , with the operator { } it allows you to key in multiple values.

 

How can I do it in DAX?

 

 

Thank you in advance,

Eric

5 Replies

  • v-haibl-msft's avatar
    v-haibl-msft
    Microsoft Employee

    Anonymous

     

    Please try with nested SUBSTITUTE function with similar DAX formula as below.

    Column1_1 = 
    SUBSTITUTE (
        SUBSTITUTE (
            SUBSTITUTE ( 'Table'[Column1], "Trust", "One" ),
            "Foundation",
            "One"
        ),
        "Endownment",
        "One"
    )

     

    Best Regards,

    Herbert

  • ankitpatira's avatar
    ankitpatira
    Community Champion

    Anonymous You can do it using DAX but it is not the only way. Easy way is to use Replace Values function in power bi via query editor. It will replace all occurences but obviously you have to do it few times for each string you want to replace. You can also use Conditional Column feature where you can specify multiple conditions (for multiple strings) and it will result in new column.

     

     

     

     

     

     

     

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi ankiipatira,

       

      Can you show me the code for multiple value replacement?

       

      However I am still interested what is the operator for DAX so allow easy replacement for the function.