Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Update column value without creating new column

Hi Team,

 

I am new to Power BI and i would like to know the best possible solution for below condition:

I would like to update column value (data source is sharepoint custom list). For example, in SQL query I would do something like this:

 

update table1

set col1= "OOF"

where col2 = "Admin"

 

Thank you in advance.

  • Anonymous's avatar
    Anonymous
    7 years ago

    Hello, Anonymous 

    Power Query

    Enter in your query, click in the FX icon near the formula bar and insert this code:

     

    = Table.ReplaceValue( #"PreviousStep" ,each [col1],each if Text.Contains([col2], "Admin") then "OOF" else [col1],Replacer.ReplaceValue,{"col1"})

     

    Change the name of the step in red and you are ready to go.

     

     

4 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hello, Anonymous 

    Power Query

    Enter in your query, click in the FX icon near the formula bar and insert this code:

     

    = Table.ReplaceValue( #"PreviousStep" ,each [col1],each if Text.Contains([col2], "Admin") then "OOF" else [col1],Replacer.ReplaceValue,{"col1"})

     

    Change the name of the step in red and you are ready to go.

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Anonymous

       

      Thank you for the prompt reply.

       

      This is exactly what I was looking for

       

       

       

  • Anonymous unfortunately you cannot update existing column but you can add new conditional column either using Power Query or DAX, if you use Power Query, you can rename the old one, add new one with the original name and then remove the old one, so one it is loaded in the model, you will see new column with original name with updated value. Hope it is helpful.

  • CerbPBI's avatar
    CerbPBI
    Frequent Visitor

    I'm looking to do the same. Any help is greatly appreciated.