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
alexaffut
New Member

Sort is not applied once column is expanded

Hi I have this Connection Query that contains a column with a list using this formula :

 

 

let
    Source = Table.NestedJoin(#"Nom Soumission", {"OV_OBJECTPART"}, #"M-Add02: ID Add+M-Add01", {"OV_OBJECTPART"}, "M02 : ID Add+M01", JoinKind.LeftOuter),
    #"Expanded M02 : ID Add+M01" = Table.ExpandTableColumn(Source, "M02 : ID Add+M01", {"Num+Date"}, {"Num+Date"}),
    #"Sorted Rows" = Table.Sort(#"Expanded M02 : ID Add+M01",{{"Num+Date", Order.Ascending}}),
    #"Grouped Rows" = Table.Group(#"Sorted Rows", {"OV_OBJECTPART"}, {{"Addenda", each _, type table [OV_OBJECTTYPE=number, OV_OBJECTPART=number, Nom projet=text, #"Num+Date"=text]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.ToList(
    Table.Transpose(
        Table.Distinct(
            Table.FromList(
                Table.Column([Addenda],"Num+Date")
            )
        )
    ),Combiner.CombineTextByDelimiter("; #(cr)")
)),
    #"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Custom", each Text.Combine(List.Transform(_, Text.From), "#(cr)#(lf)"), type text}),
    #"Removed Columns" = Table.RemoveColumns(#"Extracted Values",{"Addenda"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Custom", "Addenda"}})
in
    #"Renamed Columns"

 

 

 

Once I merge this table with an other one the data stays the way as intended.
But once the new column is expanded, the sorting is not applied.

Sort not appliedSort not appliedAs intendedAs intended

Can someone please help me? or is this a bug in Power Query?

 

1 ACCEPTED SOLUTION

I finally found the solution through the forum. Need to add Table.Buffer before the Table.Sort function to keep the sorting.

View solution in original post

3 REPLIES 3
edhans
Super User
Super User

It isn't a bug, but to the best of my knowledge, sorts do not survive a merge/expand operation. The Table.ExpandTableColumn doesn't see to have any parameter that would sort either. You'd need to apply sorts after the expansion.



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 finally found the solution through the forum. Need to add Table.Buffer before the Table.Sort function to keep the sorting.

But this table.buffer will make your pbix huge like crazy, do you have any idea how to solve it?

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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