Forum Discussion
function behavior
- 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 AddColumnWithTableColumnI'll give some feedback to Microsoft when I have a chance. Feel free to do the same 🙂
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 🙂
Table.Group misbehaves
let
Source = #table(type table [Col1 = Text.Type, Col2 = Int64.Type], {{"A", 2}, {"B", 3}, {"B", 4}}),
count_rows = Table.Group(Source, "Col1", {"count_rows", List.Count})
in
count_rows