Forum Discussion
CountRows in nested table performance issues
Hi PaulBoot ,
Here’s a way I’ve found works well and keeps things running smoothly, even on bigger files:
let
BufferedTable = Table.Buffer(#"PreviousStep"),
RowCountColumn = Table.AddColumn(BufferedTable, "RowCount", each Table.RowCount([Total.Table]), Int64.Type)
in
RowCountColumn
A couple more tips to keep things fast,Try to remove any columns you don’t need from [Total.Table] before the merge, so you’re not carrying extra data through each nested table. If you can, aggregate or count rows at the source (in SQL, a dataflow, etc.) and merge those results in, instead of doing the counting in Power Query, this is often much faster on big datasets. Make sure you turn off background data previews in Power Query while editing, so it’s not constantly re-evaluating the steps.
If you ever need to count only certain rows in the nested table (for example, only non-blanks), you can do something like: Table.AddColumn(BufferedTable, "NonBlankCount", each List.Count(List.Select([Total.Table][YourColumn], each _ <> null)))
- PaulBoot1 year agoNew Member
Thanks Rohit! That model was a long time ago - don't have it anymore, but thanks for thinking along. i can't say whether or not your proposal would have solved it, but apprecaite the effort!