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 🙂
Dicken I misread your original question 😅.
Yes, that is strange and after testing variations of your queries I can't explain it. The fact that Table.Column works in this specific situation looks like a bug.
It appears to require first adding a column (such as Unit) then adding a column using the "incorrect" function Table.Column.
I'll direct some others to look at this thread and see if they can provide an answer 🙂
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 🙂
- AlienSx1 year agoSuper User
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