Forum Discussion
Mendes094
1 year agoNew Member
Change a cell without create a new colunm
Hello, I have a table and I need change the value for 0 when Type is B. How can I do this without create a new colunm in Power query? Type Value Results A 10 10 B 20 0 C 40 ...
dufoq3
Community Champion
1 year agoHi rohit1991, this won't work in my opinion. You can't refer another column in Table.TransformColumns. That is the reason why I showed solution with Table.TransformRows.
rohit1991
Super User
1 year agoHi dufoq3,
TransformColumns cannot reference another column. Here's an alternative approach using Table.TransformRows to update the Value column without creating a new one:
let
Source = YourTable,
UpdatedTable = Table.FromRecords(
Table.TransformRows(Source, each Record.TransformFields(_, {{"Value", if _[Type] = "B" then 0 else _[Value]}}))
)
in
UpdatedTable
This method ensures the Value column is updated based on the Type without creating a new column. Let me know if you have further questions or need more clarification!