Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Power excel 2016 with mrexcel Master Pivot Tables, Subtotals, Charts, VLOOKUP, IF, Data Analysis in Excel 2010–2013 (Bill Jelen) (z-lib.org).pdf
Скачиваний:
4
Добавлен:
14.08.2022
Размер:
49.75 Mб
Скачать

PART 3: WRANGLING DATA

367

 

 

WHAT ARE THE PRODUCTS IN POWER BI AND HOW CAN I GET THEM?

Power BI is the collective name for a series of impressive add-ins for Excel. Unfortunately, Microsoft Mar- keting continues to fumble any attempts to communicate what the add-ins are and how you can get them.

Let’s start with what the add-ins do:

Power Query is a data-cleansing tool that helps you load imperfect data from many sources into Ex- cel. As you go through the steps of cleaning the data on the initial import, those steps are recorded in a new programming language called “M”. The next time you need to load and clean the data, you simply have to Refresh and all the steps are carried out. Available as a free download for anyone with Windows versions of Excel 2010 & 2013 and included in Excel 2016 on the Data Tab in the Get & Transform group.

Power Pivot allows you to create pivot tables from very large data sets. You can join two data sets without using VLOOKUP. You can write amazing new calculated fields in a new DAX formula lan- guage. Power Pivot was a free download for Excel 2010 but is not in all editions of new versions of

Excel. It is in the standalone boxed version of Excel 2013/2016. It is in Office 2016 Professional but not in Office 2013 Professional. For Office 365, you need either Pro Plus or the E3 level.

● Data Model is a subset of Power Pivot that lets you create pivot tables from two worksheets. It comes built-in to all Windows versions of Office 2013/2016. You can not build DAX in this version.

● Power BI Desktop is a free way tool to create web-based interactive dashboards based on Excel data.

Power Map is a way to plot a pivot chart on a map. You can build tours of the data and save to a video. The preview is a free download for Excel 2013 and built in to Excel 2016 as “3D Maps” on the

Insert tab.

KNOW IF YOU HAVE 32-BIT OR 64-BIT EXCEL

Microsoft has done their best to make sure you ended up with 32-bit Office. If you plan on loading 10 mil- lion rows into Power Pivot, you really need 64-bit Office. When you install Office there is a huge button for

“Install What We Think You Should Have” and a tiny link for “Advanced Options” where you can choose 3 64-bit.

If you plan on downloading any of the free downloads, you will have to know if you have 32-bit or 64-bit Excel installed. You have to download the correct version of the add-in or it will not work.

In Excel 2013, go to File, Account. Click the About Microsoft Excel in the right side of the backstage view. Look just below the title bar of the dialog box, at the end of the version number to see if you have 32-bit or

64-bit. In Excel 2010, go to File, Help. The version number is shown on the right side of the screen.

t Figure 945 This Excel 2013 is 64-bit.

As you get to the download sites from Microsoft, they will clearly label the 64-bit with 64 in the file name. The 32-bit will either have “32” or “x86”.

Figure 946 Download the correct version to match your Excel 2010.

368

POWER EXCEL WITH MR EXCEL

 

 

 

LOAD AND CLEAN DATA WITH POWER QUERY

Problem: I get a file from the ERP system that is formatted incorrectly. I routinely have to do the same formatting steps every week.

Strategy: The tools in the Get & Transform group of the Data tab started out as a free Power Query add-in for Excel 2010 and Excel 2013. While Power Query offers some tools that are similar to Excel tools, they also offer data-cleansing tools that are not available in Excel.

Power Query Tool

Compare/Contrast to Excel

Split Column

Like Text to Columns, but better options

Remove Column

Like Deleting Columns

Remove rows by Filtering

Similar to Filter

Group by

Like Data Consolidate

Fill Down

Like Ctrl+D

Unpivot Other Columns

No equivalent in Excel

Add Column

Like formulas, but new syntax

To start, choose New Query, From File, From CSV. Browse to the file and choose to Edit the Query.

As you clean the data in Power Query, your past steps are shown in the window on the right side of the screen. You can click any item in the list and modify it. This becomes a great audit trail when the internal auditor wants to know how you are producing the report.

Figure 947 All of the steps you’ve done are shown.

After you finish cleaning the data in Power Query, choose Close & Load. The data is returned to the Excel grid. A panel on the right identifies that the data came from Power Query and offers a Refresh button. Click Refresh and Excel will re-execute all of the Applied Steps on the new source file.

POWER QUERY IS EASIER TO LEARN THAN VBA MACROS

Problem: I could never figure out the macro recorder or VBA macros. Is Power Query just another macro recorder?

Strategy: While the learning curve for VBA macros is several months to 2 years, you can become very proficient in Power Query in two hours. Buy the book “M is for (Data) Monkey” by Ken Puls and Miguel Escobar.

Additional Details: As you perform Data Cleansing steps, Power Query is writing those steps in a pro- gramming language called “M”. While a few people have learned M and will write their queries from scratch, 99.9% of the time you don’t ever have to look at or edit the M code. Contrast this to the VBA Macro Recorder where 98% of macros require knowledge of VBA to edit the macro to make it work.

I HAVE MORE THAN 1,048,576 ROWS OF DATA

Problem: I am importing data from a database. By the end of the year, I will have 1.5 million rows and it won’t fit in Excel.

Strategy: Use Power Query to remove any columns or rows that you don’t need. When you are done edit- ing the query in Power Query, open the Close & Load dropdown and choose Close & Load to Data Model.

PART 3: WRANGLING DATA

369

 

 

The 1.5 million rows will be loaded behind the scenes. You can then summarize the data using a pivot table.

Alternate Strategy: Tools in Power Query such as Group By will allow you to process the 1.5 million rows and consolidate rows. If you only need to have one row per month per item, you can group by month and item, summarizing quantity and revenue. Consolidating the data might allow it to fit in the Excel workbook.

LOAD A LIST OF FILE NAMES INTO EXCEL

Problem: Windows Explorer will show you a list of files in a folder, You can sort by name, sort by date, sort by size. But sometimes it would be great to have this list in Excel.

Strategy: Power Query makes this simple.

1. Select Power Query, From File, From Folder.

2. Browse to your folder. Click OK.

3. You initially see useful columns like Date Modified, File Name, but important columns such as Size are missing. Find the Attributes column and click the Expand icon. You are now given a list of ad- ditional fields that you can add to the grid.

3

Figure 948 The Expand icon often has hidden fields.

LOAD A FOLDER OF CSV FILES INTO A SINGLE EXCEL WORKSHEET

Problem: My I.T. department products a CSV file for every customer and I have to load all of those into

Excel.

Strategy: Power Query can load all of the CSV files into a single grid. When the I.T. department adds more CSV files, you can simply refresh the query and Excel will load the entire folder again.

Follow these steps:

1. Select New Query, From File, From Folder.

2. Browse to the folder.

3. In the Preview window, choose Edit instead of Load. 4. Excel will show you a list of all files in the folder.

5. Use the filter dropdown on the Type column to remove anything that is not a .CSV file. 6. Click the icon in the Binary column header. It is two arrows pointing down at a line.

Figure 949 The label on this icon doesn’t hint at the sheet power of loading all files.

I used Power Query for over a year before I realized this button did anything. I had to read the M is for (Data) Monkey book before I realized the awesome power of loading 200 CSV files into a single Excel work- sheet in a single click. As I write this in October of 2016, the command only works with CSV files. There is

370

POWER EXCEL WITH MR EXCEL

 

 

hope it may one day work with Excel files. But I’ve met people who wrote a macro to save all of their Excel files as CSV files just to be able to use this command.

MY HEADINGS REPEAT EVERY 60 ROWS

Problem: I have one of those annoying reports where the titles and headings appear every 60 rows in my data. Or, I used the previous trick and now each CSV file’s headings appear in the data.

Strategy: Remove the headings with Power Query.

In the previous example of loading all CSV files, the data starts out with generic column names and the headings from the first CSV file are in Row 1.

In Power Query, promote the first row to be Headers using Transform, Use First Row as Headers.

Figure 950 Keep the first instance of headings as column names.

Open the Customer filter dropdown and uncheck Customer. Also uncheck Run Date, Total, or other an- noying labels.

Figure 951 After promoting the first row as headings, remove all other headings.