Import Data in Excel using Power Query

Power Query is an amazing tool to import data from almost any popular or semi-popular data source in Excel. One can import any database, which can be in any format like .txt, CSV, JSON, Access etc. or from any database form like Azure, SQL, ODBC, DBMS, Oracle, IBM etc. One can also import any website’s live data, which could be automatically updated on a given time period. Yeah! it is possible.

In addition to just importing the data from different sources, it also helps to:

  • edit the database
  • transform the database
  • delimiting the data
  • exchange the columns etc.

Note: Power Query works in MS Office 2013 and upper version only. If the add-in is missing then the same can be downloaded from https://www.microsoft.com/en-in/download/details.aspx?id=39379.

Excited! Let’s get started.

A.    Importing Text/CSV files

  1. Go to Data Tab
  2. Get & Transform Data Group
  3. Get Data
  4. Text/CSV file
  5. Select file
  6. Import

Pic1Pic-2

Clicking on the import button will open up a dialogue box in which one can delimit the data as per the requirement.

Pic-3

As shown in the screenshot above, one can either go with any of the delimiters mentioned in the list can choose custom and define our own delimiter.

B.     How to Import Folder

Instead of importing data from a single file, one can import a complete folder containing multiple fines and the same can be linked and the imported data will be updated once any change happens in the linked folder.

  • Go to Data Tab
  • Get Data
  • From Folder
  • Browse
  • Select folder
  • Ok

Pic-4

Browse the required folder and click Ok.

Pic-5

After clicking Ok, it will open another dialogue box showing 3 options-

  1. Load- It will directly load the data into Excel.
  2. Edit- It will give us an opportunity to edit the data first and load it.
  3. Cancel- Uploading gets cancelled.

PIc-6

In the screenshot above, the extension column showing the presence of more than one file format and as we need only Excel then one should click “Edit”, this will open Power Query window.

Note: A detailed explanation of the “Microsoft power query editor” Page can be referred in another blog post (provide a link here).

Further steps to edit the data-

1-      Click on Extension Filter button-> select  “.Xlsx” ->Ok/Enter

Pic-7

Right-click on Binary->Remove Another Column

Pic-8

  • Add column->Custom Column- Type a Name in newly open dialogue box Ex.-“Get Data” -> Type a formula “Excel.Workbook([Content])->Ok

Note: Formulas are case sensitive.

Pic-9

  • A new Tab “Get Data” added and now right click on the binary column and remove it.
  • On the right side of the heading “Get data”, there is a 2 headed arrow button is visible, this is an Expand buttons. Click on it to Expand the rest of the columns.

PIc-10

  • Column “GetDataKind”->Click on filter button-> select “Sheet”->Ok
  • Right click on column “GetData.Data”->click on Remove other columns.

Pic-12

  • Column “GetData.Data”-> click on expand button-> Uncheck the “use original column as a prefix”->OkPic-13
  • Once one click on Ok, all the data will get consolidated at one place, However, if Data’s heading is coming in 2nd rows, need not to worry, as one create a correct headers by clicking on the square button which is visible on the upper left corner of the database -> select “use first row as Headers”.Pic14
  • And now, go to Home tab->Select Close & Load.pic-15
  • This will load the whole database into Excel and simultaneously opens up “Query connection” pane on the right side of the screen, which shows the information about the rows/Path/Refresh etc.

PIc-16

C.    How to Get Web Data

It’s become much easier and reliable now to import data from a webpage. This will be live also.

  • Open the web page which needs to be imported into the Excel.
  • Copy the URL

Pic-17

  • Open Excel ->Data Tab->Get Data-> From Web

Pic-18

  • Paste URL->Ok

Pic-19

  • Excel will make a connection with the webpage.
  • After the connection established, one will get a new window (A list of the tables will be available, by clicking on any table, one can see the preview of the table’s data on the right side)

Pic-20

  • Select table ->close & Load.

Data auto-update setting-

  • Table’s properties
  • Click on Properties button
  • by clicking on the option ” Refresh Every” and Provide the time duration for data refresh.
  • Ok

Pic-21

Happy Learning 😊

Leave a Comment

Your email address will not be published. Required fields are marked *