Forum Discussion

ValeriaBreve's avatar
ValeriaBreve
Post Partisan
2 years ago
Solved

CountRows in a nested table

Hello, I need to count the rows of each nested table (in a column "All") of a query. I am trying to do so by adding a custom column into the nested tables and, for each cell, adding the total row c...
  • dufoq3's avatar
    2 years ago

    Hi ValeriaBreve, check this:

    let
        Source = Table.FromList({#table(null, {{"a"}}), #table(null, {{"a"}, {"b"}})}, Splitter.SplitByNothing(), type table[All=table]),
        Ad_RowCountOuterColumn = Table.AddColumn(Source, "RowCount as Outer Column", each Table.RowCount([All]), Int64.Type),
        Ad_RowCountToAllTablesInner = Table.TransformColumns(Ad_RowCountOuterColumn, {{"All", each Table.AddColumn(_, "RowCount", (x)=> Table.RowCount(_), Int64.Type), type table}})
    in
        Ad_RowCountToAllTablesInner