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

See when key Fabric features will launch and what’s already live, all in one place and always up to date. Explore the new Fabric roadmap

Reply
hgauhar
Regular Visitor

order of columns in csv DATA SOURCE

hello

i have built reports using a csv data source in power BI e.g. order of columns is col1,col2,col3

now i have another csv file with same columns but in different order e.g.col3, col1,col2, col4(a new col)

can i use the same power bi file to visualize this new csv file??

please help

thanks

2 REPLIES 2
edhans
Super User
Super User

You can, but it may throw an error on the import, or not show you column 4 at all.

 

This is a test file I just imported. Pay attention to the first line of the M code used to import the file:

let
    Source = Csv.Document(File.Contents("C:\Users\UserName\OneDrive\errors.csv"),[Delimiter=",", Columns=19, Encoding=1252, QuoteStyle=QuoteStyle.None]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type text}, {"Column3", type text}, {"Column4", type text}, {"Column5", type text}, {"Column6", type text}, {"Column7", type text}, {"Column8", type text}, {"Column9", type text}, {"Column10", type text}, {"Column11", type text}, {"Column12", type text}, {"Column13", type text}, {"Column14", type text}, {"Column15", type text}, {"Column16", type text}, {"Column17", type text}, {"Column18", type text}, {"Column19", type text}})
in
    #"Changed Type"

Notice how it says "Columns=19"

That means if I import a new file with 20 columns, column #20 will not be imported. 

You can just delete the Columns=19, or Columns=3 in your case, but there is another issue.

 

The Changed Type step automatically set the data types for the 19 columns above. Even if column #20 comes in, it will not get typed, and come into Power BI either as text (which might be ok) or as ABC/123, or Any, which is bad. So....

  • Get rid of the Columns=3 in your first step
  • Validate the data types of all of the columns and make sure they are right in the second step.

 

As @parry2k said though, after that, the order is irrelevant.



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
parry2k
Super User
Super User

@hgauhar order of the columns doesn't matter as far as column names are the same.

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
May PBI 25 Carousel

Power BI Monthly Update - May 2025

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

May 2025 Monthly Update

Fabric Community Update - May 2025

Find out what's new and trending in the Fabric community.