Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

replace the value when another column condition is true in power query editor

I have to replace the only one value i.e. Canada in test column when InventoryDeviceLocation = "CA - Winnipeg, MB - 99 Commerce Dr" 

 

renamed the columns: from Assigned user - Corporate structure - 2nd level to test

test is column name instead of Assigned user - Corporate structure - 2nd level  column

 

im using below both the codes but not replacing the value.. could you please help me on this asap

 

Table.ReplaceValue(#"Renamed columns",each [test],each if [InventoryDeviceLocation] = "CA - Winnipeg, MB - 99 Commerce Dr" then "Canada" else [test],Replacer.ReplaceValue,{"test"})

 

Table.ReplaceValue(#"Renamed columns",each [test],each if [InventoryDeviceLocation] = "CA - Winnipeg, MB - 99 Commerce Dr" then "Canada" else [test],Replacer.ReplaceText,{"test"})

 

 

  • Hey Anonymous ,

     

    Your code looks correct.

    Are you getting any error?

    Can you show the screenshot of the next step where you are replacing the value in test column?

    Also, I am assuming that you copied the value from the [InventoryDeviceLocation] column in your code as even a single space could make a difference

1 Reply

  • PC2790's avatar
    PC2790
    Icon for Community Champion rankCommunity Champion

    Hey Anonymous ,

     

    Your code looks correct.

    Are you getting any error?

    Can you show the screenshot of the next step where you are replacing the value in test column?

    Also, I am assuming that you copied the value from the [InventoryDeviceLocation] column in your code as even a single space could make a difference