Forum Discussion
peterhui50
4 years agoHelper III
Power Query, subtraction between two lists
Hello, I have columns with lists. Column [Numbers_1_3_5] has this. Column [Numbers_2_4_6] has this I want to just make a new column that finds the difference between the t...
- 4 years ago
Hi peterhui50
It's not quite as simple as in R I'm afraid, but you can use List.Zip to combine corresponding elements from a list of lists, then perform operations on the resulting list.
For your example, the code to enter in the calculated column dialog box would be something like this:
List.Transform( List.Zip( {[Numbers_1_3_5], [Numbers_2_4_6]} ), each _{1}-_{0})Regards,
Owen
OwenAuger
4 years agoSuper User
Hi peterhui50
It's not quite as simple as in R I'm afraid, but you can use List.Zip to combine corresponding elements from a list of lists, then perform operations on the resulting list.
For your example, the code to enter in the calculated column dialog box would be something like this:
List.Transform( List.Zip( {[Numbers_1_3_5], [Numbers_2_4_6]} ), each _{1}-_{0})
Regards,
Owen
- AlexisOlson4 years agoSuper User
You could also create a virtual table and add a custom column:
Table.AddColumn( Table.FromColumns({[Numbers_1_3_5], [Numbers_2_4_6]}, {"135", "246"}), "Diff", each [246] - [135] )[Diff]This returns the custom column from the virtual table.