Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago

Table.TransformColumns(Source, {{"Item",  each _ ?? "OtherColumn" , type text}}) coalesces not work

Just testing some syntax in vs code 

 

why does this work 

let
    Source =   Table.FromRecords({
        [OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0, Shipping = 10.00],
        [OrderID = 2, CustomerID = 1, Item = null, Price = 5.0, Shipping = 15.00],
        [OrderID = 3, CustomerID = 2, Item = "Fishing net", Price = 25.0, Shipping = 10.00]
    }),
  ReplacedNulls = Table.TransformColumns(Source, {{"Item",  each if _ = null then "OtherColumn" else _, type text}})
in
    ReplacedNulls

but this doesnt. Using the power query sdk in vscode to test this. I thought the coalesces should work.  Just curious if the below works for others.
let
    Source =   Table.FromRecords({
        [OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0, Shipping = 10.00],
        [OrderID = 2, CustomerID = 1, Item = null, Price = 5.0, Shipping = 15.00],
        [OrderID = 3, CustomerID = 2, Item = "Fishing net", Price = 25.0, Shipping = 10.00]
    }),
  ReplacedNulls = Table.TransformColumns(Source, {{"Item",  each _ ?? "OtherColumn" , type text}})
in
    ReplacedNulls

Cheers 

8 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    maybe its the vscode powerquery sdk 

    Could you try it in VScode ? 

      • Anonymous's avatar
        Anonymous
        Not applicable

        Vs code extension you can download power query sdk extensions

  • Yes, the error message is:"token comma expected"(in vs). Maybe it's a bug? I think you can ask Microsoft or the plugin author.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    Please be aware, Power Query SDK provides functionality related to the development and testing of Custom Connectors for Power Query and Power BI.

     

    Best Regards,

    Stephen Tao

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.