I have a list of column names:
list = {"col1", "col2", "col3"}
and a dataset ds. I want to add a new column to ds that contains the sum of the columns listed in list. As suggested here, I could do:
ds[All, <| #, "colnew" -> #col1 + #col2 + #col3 |> &]
But I cannot list the column names by hand, because the list may be very large, or I might not know the names of the columns a priori.




fis in different place(one is in the inner ofAssociation,but another out of it,and I think it is should in outside).Though they is a same operation.I think the solution is right,I mean that behavoir is expected. – yode Jul 02 '17 at 23:09Associationitself did not do that. I think the syntax is a logical consequence of these principles. For the first example in your screenshot to work, I would expectfto evaluate to a rule, list or association. – WReach Jul 03 '17 at 05:23