Forum Discussion
multiply columns by one column
Hi All
I need to transform a bunch of columns by multiplying them on row level by values in a column:
Ex in tabel below I need to multiply Column2, Column3 & Column4 by Column1
| Column1 | Column2 | Column3 | Column4 |
| 2 | 1 | 2 | 1 |
| 3 | 1 | 1 | 3 |
After transformation of columns we get:
| Column1 | Column2 | Column3 | Column4 |
| 2 | 2 | 4 | 2 |
| 3 | 3 | 3 | 9 |
It feels like one should be able to do this in one step with M code. what I basicly whant to do is: for each of these columns multiply the value on each row with the value in this column on same row.
Does anyone know if this is possible?
- Anonymous3 years ago
Sorted it out my self, this worked.
Table.FromRecords(Table.TransformRows(#"Changed Type", (x) => Record.TransformFields(x, List.Transform({"Column2", "Column3", "Column4"}, (y) => {y, each x[Column1] * _}))))
1 Reply
- AnonymousNot applicable
Sorted it out my self, this worked.
Table.FromRecords(Table.TransformRows(#"Changed Type", (x) => Record.TransformFields(x, List.Transform({"Column2", "Column3", "Column4"}, (y) => {y, each x[Column1] * _}))))