# Issues with Power Query changing the order of columns?



## tshives26 (Sep 19, 2016)

I made a comment on the video, but since its from a few years back I was searching for a better place to ask the question. Hopefully I found it  The question is in regards to this video: https://www.youtube.com/watch?v=a7E29H5ZUmE

I'm having an issue that just arose and I'm hoping  you'll be able to help me out. I've been using this method for a few  weeks and everything has been working fine. Starting today, when I get  to the step where we remove all columns except NoHeader then expand the  remaining data to our finished result, PowerQuery is "randomizing" my  order of columns for some reason. Before today, this has been working  great and keeping all my columns/rows in the order they should be. I  haven't changed anything and are still following your steps to a T. Have  you ran across this issue before? If so, what's the fix? Thanks for  your help ahead of time and keep the great vids coming!  

TL:DR - At the final expand after removing headers, PowerQuery is  changing the order of my columns for some reason. How do you prevent  this?﻿


----------



## tshives26 (Sep 19, 2016)

I noticed this thread was moved. If I posted it in the wrong place, I apologize. I could have sworn I was in this forum. Either or, I'm about up reinstall power query or something as I've exhausted just about every other option I could think of.


----------



## tshives26 (Sep 23, 2016)

Let me post some pictures to maybe help explain what my issue is. I'm assuming by the lack of response either I did not explain it properly, or others have never see this issue. Here goes nothing:

Make note of the column order of my data set in the following screenshot. (Test Suite Execution ID, Execution ID, Sequence, etc) This is immediately after I added a new custom column "Table.PromoteHeaders([data])"








Next, I go to expand the data. This is where it changes the original column order of my data set.





The order as you can see is different now. It goes Device Type, End Time, Execution ID, etc. As mentioned above, the order of columns was much different originally. 


If we click ok and go to view the data, you can see my columns are now in this new order Power Query decided for me as opposed to the order I previously had setup before starting this process.








I hope these pictures can help clear up this issue. I've been searching Google all week for a solution and I can't figure this issue out. It's really racking my brain and I'm hoping someone here with some knowledge can help me solve this issue. Thank you very much!


----------



## ImkeF (Sep 23, 2016)

Table.ColumnNames(#"Removed Other Columns1"{0}) should give you the list of your column names in the desired format.

You can either replace the string in the step "Expanded Custom1" with it or add another step with a dedicated Table.ReorderColumns(#"Expanded Custom1", Table.ColumnNames(#"Removed Other Columns1"{0}))


----------

