Forum Discussion

Dicken's avatar
Dicken
Post Prodigy
1 year ago
Solved

function behavior

I have a question ragarding function behavior, I made a mistake and used table,column rathrer than record.field,  so example table ;  #table( type table [ A = Text.Type , Unit = Any.Type] , {{"A"...
  • OwenAuger's avatar
    OwenAuger
    1 year ago

    Hi again Dicken 

    I did ask around some contacts. The general opinion is that it some sort of "leakage" of the internal representation of tables as either lists of records or records of lists. It shouldn't stricly behave this way but Power Query is erroneously allowing it in this case.

     

    Another intriguing variation is this (credit to Greg Baldini )

    let
      Source = #table(type table [Col1 = Text.Type, Col2 = Int64.Type], {{"A", 2}, {"B", 3}, {"C", 4}}),
    
      // this step yields an error for every row in "Col3" in the query preview
      AddColumn = Table.AddColumn(Source, "Col3", each Table.Column(_, "Col2"), Int64.Type),
    
      // this step does not yield an error, but crazier: it *undoes* the error in the prior step.
      // the preview here yields a "Col3" and a "NewCol" both of which have *no* errors.
      AddColumnWithTableColumn = Table.AddColumn(AddColumn, "NewCol", each Table.Column(_, "Col2"), Int64.Type)
    in
      AddColumnWithTableColumn

    I'll give some feedback to Microsoft when I have a chance. Feel free to do the same 🙂