Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
SaaM
Helper II
Helper II

Performance issue - expanding column with rowcount

Hi all,

 

I am facing a performance issues while trying to do a group by and row count and expanding table.

I have tried many options but the result is always the same, very slow performance ...

 

I Group by my table 1 then join with table 2 then develop my new column.

 

Option 1:


    #"myNewCol" = let 
        table1Filtred = Table.SelectRows(table1, (sel)=> sel[#"item"] <> null), 
        table1Filtred_tmp = Table.Group(table1Filtred, {"id"}, {{"DeveloppedNewCol", each Table.RowCount(_), Int64.Type}}), 
        #"MergedQueries" = Table.NestedJoin(table2, {"id"}, table1Filtred_tmp , {"id"}, "NewCol", JoinKind.LeftOuter),
        #"ExpandedTable" = Table.ExpandTableColumn(#"MergedQueries", "NewCol", {"DeveloppedNewCol"}, {"DeveloppedNewCol"})        
      in 
    #"ExpandedTable"

 

Option 2:

    #"myNewCol" = let 
        table1Filtred = Table.SelectRows(table1, (sel)=> sel[#"item"] <> null), 
        table1Filtred_tmp = Table.Group(table1Filtred, {"id"}, {{"DeveloppedNewCol", each Table.RowCount(_), Int64.Type}}), 
        #"MergedQueries" = Table.NestedJoin(table2, {"id"}, table1Filtred_tmp , {"id"}, "NewCol", JoinKind.LeftOuter),
        #"ExpandedTable" = Table.ExpandTableColumn(#"MergedQueries", "NewCol", List.RemoveItems(Table.ColumnNames(#"MergedQueries"[#"DeveloppedNewCol"]{0}), {"id"}))       
      in 
    #"ExpandedTable"

 

The step that takes a lot is while expanding the column as I think it recalculates the field (rowcount() from table 1) for every id.

A snapshot of my table 2 after joining with table 1 and before expandingcolumn.

SaaM_0-1616688074215.png

 

Thanks in advance

 

kind regards

Saam

1 ACCEPTED SOLUTION
Jimmy801
Community Champion
Community Champion

Hello @SaaM 

 

try this approach and let us know

let 
        table1Filtred = Table.SelectRows(table1, (sel)=> sel[#"item"] <> null), 
        table1Filtred_tmp = Table.Buffer(Table.Group(table1Filtred, {"id"}, {{"DeveloppedNewCol", each Table.RowCount(_), Int64.Type}})), 
        #"MergedQueries" = Table.NestedJoin(Table.Buffer(table2), {"id"}, table1Filtred_tmp , {"id"}, "NewCol", JoinKind.LeftOuter),
        #"ExpandedTable" = Table.AggregateTableColumn(#"MergedQueries", "NewCol", {{"DeveloppedNewCol", List.Sum, "DeveloppedNewCol"}})        
      in 
    #"ExpandedTable"

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

 

View solution in original post

5 REPLIES 5
Jimmy801
Community Champion
Community Champion

Hello @SaaM 

 

try this approach and let us know

let 
        table1Filtred = Table.SelectRows(table1, (sel)=> sel[#"item"] <> null), 
        table1Filtred_tmp = Table.Buffer(Table.Group(table1Filtred, {"id"}, {{"DeveloppedNewCol", each Table.RowCount(_), Int64.Type}})), 
        #"MergedQueries" = Table.NestedJoin(Table.Buffer(table2), {"id"}, table1Filtred_tmp , {"id"}, "NewCol", JoinKind.LeftOuter),
        #"ExpandedTable" = Table.AggregateTableColumn(#"MergedQueries", "NewCol", {{"DeveloppedNewCol", List.Sum, "DeveloppedNewCol"}})        
      in 
    #"ExpandedTable"

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

 

It worked ! The time execution was divided by 5

Thanks

Anonymous
Not applicable

Could you try this variation and letus kwnow?

 

let 
        table1Filtred = Table.Buffer(Table.SelectRows(table1, (sel)=> sel[#"item"] <> null)), 
        table1Filtred_tmp = Table.Group(table1Filtred, {"id"}, {{"DeveloppedNewCol", each Table.RowCount(_), Int64.Type}}), 
        #"MergedQueries" = Table.NestedJoin(Table.Buffer(table2), {"id"}, table1Filtred_tmp , {"id"}, "NewCol", JoinKind.LeftOuter),
        #"ExpandedTable" = Table.AggregateTableColumn(#"MergedQueries", "NewCol", {{"DeveloppedNewCol", List.Sum, "DeveloppedNewCol"}})        
      in 
    #"ExpandedTable"
edhans
Super User
Super User

Try adding Table.Buffer() around the Table.Group() step. That sometimes helps to speed up this kind of operation.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

I tried to add as suggested the Table Buffer:

- before 

- after

- before and after

the Table.group but the performance remains roughly the same.

 

I was wondering if instead of using the Table.Rowcount(_) I can use something else that gives me directly the value without expand the column.

Inside every Table of my non Expandedcolumn I have the id and the row count and when i expand the column I select only the rowCount field :

SaaM_0-1616752757306.png

 

I do not know if i can process differently, maybe in DAX ?

 

Thanks

Kind regards

Saam

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors