This M (Power Query) function gives this error "[Expression.Error] We cannot convert a value of type Function to type List." The objective is to output a table column being the difference between two source columns.
For Example: • 1, 667
let
Source = Table.FromRecords({
[row = 1, first = "1234", second="567"],
[row = 2, first = "9876", second="543"],
[row = 3, first = "5437", second="890"],
[row = 4, first = "2321", second="550"]
}),
Source2 = Table.FromColumns(
{Source[#"row"], each Source[#"first"] - Source[#"second"]},{"row","diff"})
in
Source2
Could anyone please point out the error? I am trying to subtract one existing column from another and put the result in a new column
The syntax for the Table.FromColumns function is incorrect. Are you just trying to do this?
let
Source = Table.FromRecords({
[row = 1, first = "1234", second="567"],
[row = 2, first = "9876", second="543"],
[row = 3, first = "5437", second="890"],
[row = 4, first = "2321", second="550"]
}),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"first", Int64.Type}, {"second", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each [first]-[second]),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"first", "second"})
in
#"Removed Columns"