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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Chrisjr
Helper IV
Helper IV

reorder columns dynamically

I have the following table:

 

BrandVersion01/202302/202304/202306/202307/2023
AA1CV50080089045608045
AB5CVnullnull75048909650
AC1CV300null89079087980

 

In my transfmoration steps , I need to add a custom columns then move it just after the column Category but this has to be dynamic as same transformations steps will be apply to other files.  

 

The column's names for "Brand" and "Category" will never change. 

The number of columns can change. 

 

So what I did is:

= Table.AddColumn(#"changetype", "Column4", each "Price")

= Table.ReorderColumns(#"Added Custom",{"Brand", "Version", "Column4", "01/2023", "02/2023", "04/2023", "06/2023", "07/2023"},MissingField.Ignore)

 

 

Now , I want to apply the same steps on the below table : 

BrandVersion01/202302/202304/202306/202307/202308/2023
AA4CVnull1805008008908090
ABFDnull505750489096508075
ACFD10980300null8908090

 

However, the issue I get is the following : after the ReorderColumns step, the last column is "07/2023" instead of being "08/2023".

 

How can I reorder the colums in a dynamic way so that extra columns will not be moved before the "07/2023" column? 

 

Many thanks

1 ACCEPTED SOLUTION
wdx223_Daniel
Community Champion
Community Champion

= Table.AddColumn(#"changetype", "Column4", each "Price")

= Table.ReorderColumns(#"Added Custom",List.InsertRange(Table.ColumnNames(#"changetype"),2,{"Column4"}),MissingField.Ignore)

View solution in original post

2 REPLIES 2
Chrisjr
Helper IV
Helper IV

many thanks @wdx223_Daniel 🙌

wdx223_Daniel
Community Champion
Community Champion

= Table.AddColumn(#"changetype", "Column4", each "Price")

= Table.ReorderColumns(#"Added Custom",List.InsertRange(Table.ColumnNames(#"changetype"),2,{"Column4"}),MissingField.Ignore)

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.