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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

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
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.