Forum Discussion
How to edit value of a single cell
I want to change the value of a single cell, the columns (that comes from a query) looks like this:
type ID Index
---- -- -----
R 0 1
R 0 2
R 0 3
V 1 4
V 1 5
I want to change the value of ID in the first row from 0 to 5, so that I have:
type ID Index
---- -- -----
R 5 1
R 0 2
R 0 3
V 1 4
V 1 5
How do I achieve this? I tried with:
Table.AddColumn(#"Changed type", "ID2", IF ([Index] = "1" and Query([ID]) =
"0") THEN "5" ELSE Query[ID])But this didnt work.
M is case sensitive. Please try this syntax instead. This assumes your ID column is Whole Number. If it is text, then use "0" and "5".
= Table.AddColumn(#"Changed Type", "Custom", each if [ID] = 0 and [Index] = 1 then 5 else [ID])
Pat
3 Replies
- mahoneypat
Microsoft Employee
M is case sensitive. Please try this syntax instead. This assumes your ID column is Whole Number. If it is text, then use "0" and "5".
= Table.AddColumn(#"Changed Type", "Custom", each if [ID] = 0 and [Index] = 1 then 5 else [ID])
Pat
- AnonymousNot applicable
I would first separate that row with a duplicate table, and then TableName{0}. Then I would remove the first row from the original table.
Go back to your single row, and right click on the value to replace the value. Then Append your single row to the original table (where you removed the first row) as a new table.
--Nate
- AnonymousNot applicable
I'm having a hard time to follow this. Would you mind explaining with some pictures?