How to Use Power Queries in Excel


Though tech tools offer a wide variety of data management solutions, consolidating information from multiple sources remains a challenge. Making sense of disparate datasheets often relies on manual effort.

9ff7a4fe 5293 496c acca 566bc6e73f42 - How to Use Power Queries in Excel

This is where power query can help by wrangling data from various origins into an integrated view.

As a marketing consultant, I work with multiple teams across a client’s business. To get a true picture of what’s going on with a SaaS company’s revenue funnel, for example, I typically need data from marketing, sales, customer success, and product.

However, the data I need typically gets collected across multiple locations and in different formats. Piecing everything together means getting everything in one place, in the same format, and able to be manipulated in whichever way is needed.

So, power query has been very useful to me over the years, and it’s not as complicated as you might think.

With power query, you can import, clean, transform, and merge datasets from multiple sources. Once you know how to use it, gathering and interpreting data from diverse sources becomes a whole lot easier.

What is a power query?

Power query is essentially a technology you can use within Excel to connect datasets together within an Excel spreadsheet. You can use power query to pull data from a range of sources, including webpages, databases, other spreadsheets, and multiple file types.

Once the data is imported, you can also use the power query editor to clean and transform the data. Finally, you can import the transformed data into your existing spreadsheet.

Common actions you can use in the power query editor after importing data include filtering, removing duplicates, splitting columns, formatting data, and merging data.

The core benefit is that tasks that would take you hours to do manually can be performed in minutes with power query. Plus, you can repeatedly use the same cleaning or transformation actions again at the click of a button when the data sources are updated.

With any advanced feature in Excel, there is a bit of a learning curve. But while it might take you a couple of tries to get familiar with power query, it has a pretty user-friendly interface once you know where everything is.

How to Use Power Queries in Excel

When learning how to use something like power query, the most useful method is with an example. The steps below can be applied to any type of data set, and the functionalities highlighted can be replaced with other ways to use queries as needed.

In this example, I’m pulling together sales data from two different geographic regions for analysis. The data comes from the U.S. and the U.K., with formatting and currencies that are written differently and formatted differently across two spreadsheets.

My goal is to combine these data sets in one sheet, with the data cleaned and easily interpreted and analyzed in one place.

Step 1. Open Excel and access power query.

First things first, open the main spreadsheet you’ll be working from. In this case, I’ve opened my USA sales spreadsheet, as this is where I want to clean and combine data.

In the main ribbon, click on “Data.” You’ll see “Get Data (Power Query)” as the first item in the Data ribbon.

Gl6qh7F36C43AE7Qi4Xoazkx8xlr22GoGikn j O7U gKn pRK eFIIA5I8zDODBe Vl9ybmpfshIMqAtbdL YdL NEys7q9jyKihZH 3P oigziDQ6ty5nR8ZHMrPMjqiwKPL aERC5BzUDoQ8dEK4 - How to Use Power Queries in Excel

Step 2. Import your data.

Click on the dropdown to access your power query options.

zdkysV4JeBFdnnIvygIXxZL16lQxkNm3eUOVJM k KQisO zAIiJweIo0VHkL2ez1DPO1TvmxJawZIXp p QU NFsfGIAYNdT7dWpa z7UBzR3Jf5Fn9C 3eYsr6ppsF0MBARh F6crzboSMCwlyKUM - How to Use Power Queries in Excel

In this first step, we want to hit “Get Data,” so we can start a query using the data in the U.K. sales spreadsheet.

Clicking this option will open a window where you can choose a data source. As you’ll see, it’s possible to pull data from a wide range of sources, including shared SharePoint files.

yEmjT1sAxlWmvNPMsAxcyZieWA9y TQGb7U7xqngikce36V MmN9 99vAl1  A JC5NRYTUpV ItNQRioKIN SHjwJ57Dav19WqYrN pNFfNU5OPxA6qFbLnrw2gkfHNDrLRdNaM7N8u1QMqtAQkP4o - How to Use Power Queries in Excel

In this case, we’re selecting “Excel workbook” to access the file that is stored locally on my computer. After making this selection, you simply browse your files for the right spreadsheet and hit “Get Data.”

hazyisWacf8rn2CT6wQaHOh 7PNTG7g8A EbFv6u0TbQWE5JHls72G9wdk3cC fcGeJvnQdBFj6hPcxrSFeETX7zYZEYs TUn8mGiRw0KUKzYxIP2CWI6J vU SvmYPj8oNOs24oXn X2WE3lFjIAyE - How to Use Power Queries in Excel

Then, on the following screen, hit “Next.” From here, you can select specific sheets that you want to import. You’ll be able to preview the data before hitting “Load” to finalize the import.

Sm4kS2DJAn7pcBtg0WePVibtk4HH6Uv7LFxJKReWGNMxgjJg xrBeuAvUrAKdNFz39HHACAG0r53WNZEHbQIDOZTH9GH7JLBQpSIMuBuwbIX9rAqQLKO2a3dOu40hxuc2BUZ2F1u4bd4Dsy4X6gsU7I - How to Use Power Queries in Excel

If you select “Load” at this stage, power query will import the data into a new tab on your existing spreadsheet.

From there, you can select “Data” and “Launch Power Query Editor” to perform mass cleaning or updating of the imported data.

U5 wm9aX435xFXGVm1uPKTcDUDIHD XOOupe1yJmkvc0mdSZ6nctmEQ5IcGp03 Y2bqFNpfV9qwPlO8f9N0WHeaaQuHTe3soyA90MSMsMN3EXZK4k5C2jSc N7P I59U4Y4Gw5YxMA8dmxJkrNer00Q - How to Use Power Queries in Excel

Step 3. Cleaning imported data.

If you prefer to clean your data before you import it, you can do so during the import stage.

Instead of selecting “Load” during the import process, you can select “Transform data,” which opens the Power Query Editor just like in the previous step.

KOqeGZizGMypd0EKq7xvHsBf4gx0A0KPKcQyECU877VFqkEJPvMfH  arm7mIX 6xzQVFkB2YWwRgP2ipw4xfiE84a2g9d0rLCpTJOhNkQMRe0CDrJ4WwPioRkMkZrQyfVn08QcAi7iJu7r4lIJrKt4 - How to Use Power Queries in Excel

ro9ebdF1pDszzhl2KvQ OlQiTFHR7qClvWQg4G4jgDbnr0PqqWuPActFD75CNnLs78uoiDGqAVO LeGefCaa 660P0soo cP8r8AcW99J2aFwA7vVJR 6I9WCEF0a AO19A c k5eqQzOV8MQq2zOgU - How to Use Power Queries in Excel

For instance, the U.K. sales sheet contains the same data as the U.S. sheet, but it’s not formatted correctly. The currency format is not applied to the currency cell.

So, in Power Query Editor, I can select the “Transform” tab to edit the data before I import it (I could also do this if I imported the data first and then opened the Power Query Editor).

f2lmLFee3ARrk0hIp BOIv4v8lppFPu9tSpSLcJpjm96KrFK6U4eQddh mulTc3w3g6jkz5rDOwHkzDNlYmFNM4Ke 0myyWoZmqAZ6lzTuZrlIG0FVNKJFy26B8jrclgWHM5QSpCvL7AwGSJYXi6BUA - How to Use Power Queries in Excel

t9f2r1lXkJ6izRTwQgP JYxP9U ExmU8ILjH3BPwERXaq6hVDd 88VVZ037dXzAcuOZgk8hj3vF4gZKVLa7Bqm4Z7Rj6rKkuL8Hv0osmMWOtZwYrCcM eb 061CgjGzgTOvc6zp11M2hmcM8355S7mw - How to Use Power Queries in Excel

As you can see, there are tons of options available to you here. In this instance, I’m going to select the Currency column and selecting “Data type.”

2PnTz3vn7 poj79wOtWfYXvw Qe 6G ox3265UmzQjXbxwxfQk2VILSVSSDwhi9pGQF8ZiKTJzG SxzDRJPDMMcsN7iaKagaUi7LDXfLIbmXTzLT4GMtqeDekktYPyqHiT5vqRzBYHYeG9CJv4oCV5s - How to Use Power Queries in Excel

From there, I can select the Currency option and change the value to USD.

Step 4. Load your transformed data.

The final step is adding this cleaned and transformed data into my existing spreadsheet. In Power Query Editor, navigate back to the “Home” tab and click “Close & load.”

ChEmraqsj 8dSee0G3FdYoZQzmCssGzL3F S7v2qP3WF9i44xpsn9VmIJevx5oa GiJlpkEbMtjplE eVFEPQeudm6cjZ05fFK54VX4kQvG4EFa5MrUoye QKkAmubRT  e3r njJRCaYL wu9lCboM - How to Use Power Queries in Excel

Excel will now load this query into a new tab on your spreadsheet.

B HU wptGfgGyhK3UJdlJ0tMO1QafU530cL2rAkwUIHRbB6Y FpfsaW4rFOnlQvbuS J1evGRc1ig8SGz8oOAUPlEyX4wsLoOOkIYti96miBl cmX1RNWVZTh8rRPs2Z46UgRVgDx on HD1XYUI2BY - How to Use Power Queries in Excel

This simple step-by-step process shows you how to get started with accessing and using power query.

The use cases for power query, however, are almost endless due to the wide variety of data you can import and clean, and the types of transformations and data manipulations you can perform.

So, let’s take a look at some examples of what you can use power query to do.

Power Query Examples

Consolidating Data From Multiple Spreadsheets

Whether you’re working with multiple workbooks of your own creation or having files sent your way from other people, the need to consolidate data into one sheet is a fairly common problem.

Power query makes this a pretty straightforward task.

First, make sure all the workbooks you want to consolidate are saved in the same folder. Where possible, make sure they all match in terms of having the same column headings.

Open up Excel to a blank workbook and access power query with the “Get Data” option.

Select your data source as “Excel workbook” and choose your first file. If your sheets are all formatted the same, you won’t need to do anything else here. Simply hit “Load.”

xd9hUKAIEHKwH4LgmwG94eYZg4S60InahRraXmeEbF15lfyrUo8D6p FU49KATpvSAZOJ7Vak46KIc4M9XJPInFjSwbWr1aMim1 jEyz9HNWZtLLvfJpSDe4o2sDl0keOgm7yJwR8Yq08WZtDMf1vWI - How to Use Power Queries in Excel

Next, you’re going to import your other spreadsheets. But, instead of performing this first step the exact same way, you’re going to append the other sheets to this existing query that you’ve just created.

In the sheet, open power query again and select the second workbook from your list when importing a file. Instead of hitting “Load,” select the “Transform Data” option.

N3cz6KriuD 5Dh2TT0uDgELOJBoVPj7QQL4F GpuOyG5vImmTjIsBhVo3axLvybBrppO7UuzirErQB1nIljLoa7vkTkYL88hpQ29sSwxOK4wmILVzsTDTiSM967gZvE0nioyh FTMX0k1WcNSdiyK0Y - How to Use Power Queries in Excel

Now, you should see both queries available in the Power Query Editor on the left side panel.

DNHf9irr10VFf2fIBmz6oxnjBQoQYSTOV7Hy DkYa8yVkpF59 1T Z7fDp5Ff44c08hAMbaIlM  owWYJrMlbzUmspC8OCvTJt8IZuwVxTIv2gJVSMxDTuEyq7cgeTwJ2fjkM8A3pgBuO qHKaWFjN4 - How to Use Power Queries in Excel

On the right-hand side of the ribbon in Power Query Editor, you’ll see a “Combine” button with a dropdown containing options to merge or append queries.

Ptwy z4VmFsRaNmpct9ATk5pXOr3QFZ6rr7dJ0ArbizDS3n4grqK7ZH4TAhbomGSi8tzxUR3m884xYJjtCCoVEOfdCsWTE2l1DX3YT8fCCVNDFbZHnVhxwCav1sXs6ktR06ObWVLURg5NVApp0B1LYM - How to Use Power Queries in Excel

From the dropdown, select “Append queries as new.” Select the tables as you’d like to append one to the end of the other, and hit “Ok.”

cpVf1gWx1HApxhEQ2gQogBd0upJpNNEElwMV65s69rnTtSm0L5QnYGdkjta 9EB6 pEa8tc68AxMk2RRmLk17 oFebQgk2j4VfQ8rMakjGzf6Ytgq pYuxEGoRfqsG2VzeGhrrPOyPJhl3w8E8VzJwk - How to Use Power Queries in Excel

Power query will append the two tables together in one tab on your sheet. You can perform this action with two spreadsheets or multiple spreadsheets, depending on your needs.

Cleaning Up Data Before Importing

Sometimes, you can be dealing with a messy spreadsheet. Formatting and styling are all over the place, and you want to make sure it’s as clean and tidy as possible before importing.

Power query makes this an easy part of the process as you import data, so you don’t have to spend time manually cleaning things up afterward.

A simple example is a spreadsheet where some text is capitalized, and some is not. So, the goal is to convert everything into sentence case before adding it to your existing sheet.

Let’s say the sales team in France has sent us their sales report. It looks great, but some text in the Country ID column is in all caps, and some is not. Plus, random spaces have appeared in the country name that need to be fixed, too, or we’ll struggle to properly pull the data into pivot tables and other reporting.

In your sheet, open power query and import the file with the messy data. Click “Transform data” rather than importing it straight away.

First, find the column with the mixed-up capitalization and extra spaces. Right-click on the column and click “Transform column,” then “Text transforms” and, finally, “Trim.” This will remove any extra spacing that could interfere with manipulating the data.

yT6gpLf vw lANEwBofRTc8skw6wfaKsPd2TFo gmDxiqU6Ob gxl1FGg3CouIgzkx rjEXwDSyEymsQw25kqSX2J tF80KoeygA0nhqozU0hLvf2yIElTaKGKJSKCLUeGa3twrMJeDFWw8PCzHIUXU - How to Use Power Queries in Excel

Right-click on the column again, and this time, click “Capitalize Each Word” from the options. You may need to first select “lowercase” to fix any All-Caps words and then use the “Capitalize Each Word” option.

Now, you can click “Load” for your cleaned data to import into your Excel sheet.

IQ7E4w7cQ4fvhlj7IrITN6AF1WgOAcM 3mekDYahF93lexg4q4QZ5f8GPw7R7vlrwoYbxUuRWGVD MpC4ABeIKemr2hhsjxyxgDnNF77zx3i653kzv4ris5J4vcTQ6RolhyWdhjX14T0Ut8JbqOL1Z0 - How to Use Power Queries in Excel

Unpivoting/Pivoting Data to Improve Analysis Capabilities

Another common challenge with Excel is receiving data in a way that makes it difficult to manipulate and analyze, specifically when you want to switch around columns and rows — or “pivot” the data.

In this example, we have survey data where the columns are parsed out by respondents. Ideally, we’d like it parsed out with the columns as the survey questions.

First, open a blank Excel table and import your sheet using power query.

Like the previous example, instead of clicking “Load,” we first need to click “Transform data.”

69MHf duDEbEmeRI3y5e J6JORlP8oQOpSPFnTuS2i2TWSkBMZh FsHkR0VfrC33ACelX4oTOn0tJHcSkodySBUhAet8J47u4ahx2t60JVdr7REEbPBjjlZK2oW zEAj4 PkCN1XinzP8lOBGgVkV6w - How to Use Power Queries in Excel

Now that Power Query Editor is open, navigate to the Transform tab in the ribbon. Select all the survey question columns together, and click “Unpivot columns” and then select “Unpivot only selected columns.”

qffGB3vF63Bl1in7OvewR0fUg4izhwul2oqqBfzcO6ggdHQWp8SzGY8rqgoMOBu37lTshNcR bo6SGlP0pxZFYh SgY2ZVSTAPZaBJkd6lblmCVn9sqhjCzbNwVi z40L7s2gbt5ZtSj5aSybLIyYhc - How to Use Power Queries in Excel

Power query takes the selected columns and parses out the data by the attributes and values of the questions. Navigate back to the “Home” tab and hit “Close & load” to use the unpivoted data in your spreadsheet.

PEeH1COS R42LVjDkt00IcVjGx7A9S8YWB 5BKsxjJATE4cei6Gftu0jP2tEdMAy evNb2Od9jZ6UR4mYEPpdUGNfb2HFVvwg0QsKJ85rMfebUzac JlYDlCWK yLzBA3YbN w1DIO9jVwEhyNVNvpE - How to Use Power Queries in Excel

Get Experimental With Power Query

In the grand scheme of tools, Excel is amongst the most powerful when it comes to sorting, cleaning, and transforming the type of data that gets used in day-to-day business operations across multiple departments and teams.

While it can take a little while to get familiar with all the features and functionalities of something like power query, it’s well worth the effort.

Even with relatively simple spreadsheets that just contain a lot of data, power query can cut your cleaning and transforming time down significantly, so you can get into important analysis and decision-making much quicker.

7912de6f 792e 4100 8215 1f2bf712a3e5 - How to Use Power Queries in Excel

ptq.gif?a=53&k=14&r=https%3A%2F%2Fblog.hubspot.com%2Fmarketing%2Fpower query&bu=https%253A%252F%252Fblog.hubspot - How to Use Power Queries in Excel



Source link

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

We Know You Better!
Subscribe To Our Newsletter
Be the first to get latest updates and
exclusive content straight to your email inbox.
Yes, I want to receive updates
No Thanks!
close-link

Subscribe to our newsletter

Sign-up to get the latest marketing tips straight to your inbox.
SUBSCRIBE!
Give it a try, you can unsubscribe anytime.