Forum Discussion
Anonymous
4 years agoNot applicable
Change multiple values of multiple columns at once
Hello all, I am starting to learn m code a little bit more. The problem I have got now is probably very easy to solve but unfortunately at my level of knowledge I am stuck with what I have got al...
- 4 years ago
are you sure the code of #"ColumnNames" is correct? it's remove the last 24 column names.
#"Test" =Table.ReplaceValue( #"SourceMod","","",(x,y,z)=>Text.Combine({"ABCD-",x}),#"ColumnNames")
Anonymous
4 years agoNot applicable
I don't think that in this case the accumulated function is the most suitable, in terms of efficiency.
Try the following diagram. The only difficulty is selecting your 24 columns.
I used the list.range function to select 3 columns starting from the index {2} that is the third one, but this is just to give an example.
In your case, where are the 24 columns or how can they be identified by the name?
let
Origine = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Jcm5DQAwCATBXi4mAWxwL4j+2zBPMlppI8Ag8DJKcQ1JgU5ZRi3MZ3XqMp7CHzI/", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Colonna1 = _t, Colonna2 = _t, Colonna3 = _t, Colonna4 = _t, Colonna5 = _t]),
cols=Table.ColumnNames(Origine),
colnames=List.Range(cols,2,3),
ttc=Table.ToColumns(Origine),
mycols=List.Range(ttc,2,3),
lt=List.Transform(mycols, each List.Transform(_, (e)=>Text.Combine({"ABC-",e})) ),
tfc=Table.FromColumns(lt,colnames)
in
tfc
Or, perhaps even better, the solution proposed by wdx223_Daniel
Origine = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Jcm5DQAwCATBXi4mAWxwL4j+2zBPMlppI8Ag8DJKcQ1JgU5ZRi3MZ3XqMp7CHzI/", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Colonna1 = _t, Colonna2 = _t, Colonna3 = _t, Colonna4 = _t, Colonna5 = _t]),
cols=Table.ColumnNames(Origine),
colnames=List.Range(cols,2,3),
trv=Table.ReplaceValue(Origine,null,null,(x,y,z)=>"ABC-"&x, colnames)
in
trv