Hi,
I have been able to achieve the first part like so:
by inserting this code:
= Table.ReplaceValue(#"Source", each [SUP1], each [SUP1]*[Operator], Replacer.ReplaceValue, {"SUP1"})
I am able to change the value of SUP1 as below:
However I want to change the values of a range of columns, not just the SUP1 column.
How do I change the replace value code to affect all the Columns in the table e.g SUP2 SUP3 SUP4...
Thanks!
Solved! Go to Solution.
Hi @kgiboin ,
In your current data format, you would not be able to apply this to multiple columns at the same time - you would need to create a new replace step for each [SUP2], [SUP3] etc.
However, you should really unpivot your SUP columns (multi-select [PART NUMBER] and [Operator] then Transform tab > Unpivot Columns (dropdown) > Unpivot Other Columns).
This will firstly allow you to perform your multiplication replacement step generically on a single column ([Value]), but also restructure your data into the most efficient format for reporting.
Pete
Unpivoting is definitely the best way to go but it is possible to do multiple columns simultaneously even without explicitly referencing each one if you do some fancy row transformations.
Table.FromRecords(
Table.TransformRows(
#"Previous Step Name",
(row) => Record.TransformFields(
row,
List.Transform(
List.Skip(Record.FieldNames(row), 2),
(name) => {name, each Record.Field(row, name) * row[Operator]}
)
)
)
)
I found another way to do it without unpivoting:
= Table.FromRecords(Table.TransformRows(#"previous step name",(row) => Record.TransformFields(row,List.Transform(List.Skip(Record.FieldNames(row), [enter the nth column you want the formula to start]),(name) => {name, each Record.Field(row, name) * row[#"Operator"]}))))
Hi @kgiboin ,
In your current data format, you would not be able to apply this to multiple columns at the same time - you would need to create a new replace step for each [SUP2], [SUP3] etc.
However, you should really unpivot your SUP columns (multi-select [PART NUMBER] and [Operator] then Transform tab > Unpivot Columns (dropdown) > Unpivot Other Columns).
This will firstly allow you to perform your multiplication replacement step generically on a single column ([Value]), but also restructure your data into the most efficient format for reporting.
Pete
Unpivoting is definitely the best way to go but it is possible to do multiple columns simultaneously even without explicitly referencing each one if you do some fancy row transformations.
Table.FromRecords(
Table.TransformRows(
#"Previous Step Name",
(row) => Record.TransformFields(
row,
List.Transform(
List.Skip(Record.FieldNames(row), 2),
(name) => {name, each Record.Field(row, name) * row[Operator]}
)
)
)
)
Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.
Put your data visualization and design skills to the test! This exciting challenge is happening now through May 31st!
At the monthly call, connect with other leaders and find out how community makes your experience even better.
User | Count |
---|---|
140 | |
22 | |
20 | |
14 | |
13 |
User | Count |
---|---|
161 | |
33 | |
33 | |
23 | |
18 |