{"id":7068,"date":"2014-03-01T00:00:19","date_gmt":"2014-03-01T00:00:19","guid":{"rendered":"http:\/\/craftydba.com\/?p=7068"},"modified":"2016-04-19T20:31:05","modified_gmt":"2016-04-19T20:31:05","slug":"power-query","status":"publish","type":"post","link":"https:\/\/craftydba.com\/?p=7068","title":{"rendered":"Power Query &#8211; Part 1"},"content":{"rendered":"<p>In recent months, there has been a big push for self service business intelligence tools by Microsoft. The center of this universe is Microsoft Excel, a common application used by the typical data analyst.<\/p>\n<p>The following four products started off as add-ins for Excel.  Now, some of them are a integral part of MS Office 2013.<\/p>\n<ul>\n<li>Power Query<\/li>\n<li>Power Pivot<\/li>\n<li>Power View<\/li>\n<li>Power Map<\/li>\n<\/ul>\n<p>It is not surprising that these four business intelligence products have an offering in <a href=\"http:\/\/www.microsoft.com\/en-us\/powerbi\/default.aspx\">Office 365<\/a>. I really like office 365 as a platform to share the final analysis with your team, department and\/or company. Like any data in the cloud, caution should be taken when it is confidential information that is governed by auditing rules like <a href=\"http:\/\/www.hhs.gov\/ocr\/privacy\/hipaa\/administrative\/privacyrule\/\">HIPAA<\/a> or such.<\/p>\n<p>Today, I will start talking about Power Query which is a self service ETL tool. This tool was <a href=\"http:\/\/blogs.msdn.com\/b\/powerbi\/archive\/2013\/08\/29\/try-the-latest-power-query-update.aspx\">released <\/a>in August of 2013. The <a href=\"http:\/\/office.microsoft.com\/en-us\/excel-help\/microsoft-power-query-for-excel-help-HA104003813.aspx\">online help<\/a> is a good place to start learning about this tool.<\/p>\n<p>Because these tools are relatively new, I found out that once in a while the add-in will freeze. I suggest using a virtual machine so that rebooting the operating system does not cause you real down time. I am hoping that these tools mature over time and this annoyance will go away.<\/p>\n<p>The first step in using Power Query is to download the add-in <a href=\"http:\/\/www.microsoft.com\/en-us\/download\/details.aspx\">here<\/a> from the Microsoft site. Please read the system requirements. This version requires the Dot Net Framework 3.5.  You might have to install this first as a prerequisite. Next, run the setup program as shown here.<\/p>\n<p><a href=\"https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A01-power-query-install-requires-dot-net-3.5.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A01-power-query-install-requires-dot-net-3.5.jpg\" alt=\"A01-power-query-install-requires-dot-net-3.5\" width=\"508\" height=\"398\" class=\"aligncenter size-full wp-image-7081\" srcset=\"https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A01-power-query-install-requires-dot-net-3.5.jpg 508w, https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A01-power-query-install-requires-dot-net-3.5-300x235.jpg 300w\" sizes=\"auto, (max-width: 508px) 100vw, 508px\" \/><\/a><\/p>\n<p>The Power Query tool is built to grab data from various sources and mash it up in MS Excel. <\/p>\n<p>The data can be stored as either a worksheet with a million row limit. Or in the data model that is managed by the xVelocity in-memory analytic engine. This engine uses a column store philosophy that does very well with non-unique data. It can produce some high compression ratios.<\/p>\n<p>Okay, enough about the tool. Let&#8217;s get down to business by extracting, translating and loading (ETL) data into Microsoft Excel.<\/p>\n<p>The get external data section of the ribbon is where we will start. <\/p>\n<p><a href=\"https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A02-power-query-get-external-data.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A02-power-query-get-external-data.jpg\" alt=\"A02-power-query-get-external-data\" width=\"1001\" height=\"572\" class=\"aligncenter size-full wp-image-7085\" srcset=\"https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A02-power-query-get-external-data.jpg 1001w, https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A02-power-query-get-external-data-300x171.jpg 300w\" sizes=\"auto, (max-width: 1001px) 100vw, 1001px\" \/><\/a><\/p>\n<p>I know there is a data set in Wikipedia that has abbreviations for US states in a United States Postal Service (USPS) format.  I want to add this data to my model for analysis.<\/p>\n<p><a href=\"https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A03-on-line-wikipedia-information.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A03-on-line-wikipedia-information-1024x533.jpg\" alt=\"A03-on-line-wikipedia-information\" width=\"665\" height=\"346\" class=\"aligncenter size-large wp-image-7087\" srcset=\"https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A03-on-line-wikipedia-information-1024x533.jpg 1024w, https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A03-on-line-wikipedia-information-300x156.jpg 300w, https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A03-on-line-wikipedia-information.jpg 1637w\" sizes=\"auto, (max-width: 665px) 100vw, 665px\" \/><\/a><\/p>\n<p>By clicking the on-line search button, I can enter the key words to find this public data set. <\/p>\n<p><a href=\"https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A04-search-online-wikipedia-dataset-usps-states.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A04-search-online-wikipedia-dataset-usps-states-1024x781.jpg\" alt=\"A04-search-online-wikipedia-dataset-usps-states\" width=\"665\" height=\"507\" class=\"aligncenter size-large wp-image-7092\" srcset=\"https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A04-search-online-wikipedia-dataset-usps-states-1024x781.jpg 1024w, https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A04-search-online-wikipedia-dataset-usps-states-300x229.jpg 300w, https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A04-search-online-wikipedia-dataset-usps-states.jpg 1331w\" sizes=\"auto, (max-width: 665px) 100vw, 665px\" \/><\/a><\/p>\n<p>Choose the edit option to start translating the data.<\/p>\n<p>The Query editor allows you to apply translations to the source data.  Each step is saved so that it can be replayed during a refresh (re-import). Please note, the load settings determine the ultimate destination for the data.<\/p>\n<p><a href=\"https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A05-power-query-sort-filter-remove-columns-rename-columns.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A05-power-query-sort-filter-remove-columns-rename-columns.jpg\" alt=\"A05-power-query-sort-filter-remove-columns-rename-columns\" width=\"1005\" height=\"865\" class=\"aligncenter size-full wp-image-7094\" srcset=\"https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A05-power-query-sort-filter-remove-columns-rename-columns.jpg 1005w, https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A05-power-query-sort-filter-remove-columns-rename-columns-300x258.jpg 300w\" sizes=\"auto, (max-width: 1005px) 100vw, 1005px\" \/><\/a><\/p>\n<p>Here are some of the translations I performed to cleanup the USPS data.<\/p>\n<ul>\n<li>Get Source Data<\/li>\n<li>Sort Rows<\/li>\n<li>Filter Rows<\/li>\n<li>Remove Columns<\/li>\n<li>Rename Columns<\/li>\n<\/ul>\n<p>Just like many tools, the Power Query is built upon a language. Clicking the advanced editor brings up the Power Query formula that matches the saved steps.<\/p>\n<p><a href=\"https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A06-power-query-advanced-editor-internal-language.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A06-power-query-advanced-editor-internal-language-1024x671.jpg\" alt=\"A06-power-query-advanced-editor-internal-language\" width=\"665\" height=\"435\" class=\"aligncenter size-large wp-image-7097\" srcset=\"https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A06-power-query-advanced-editor-internal-language-1024x671.jpg 1024w, https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A06-power-query-advanced-editor-internal-language-300x196.jpg 300w, https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A06-power-query-advanced-editor-internal-language.jpg 1067w\" sizes=\"auto, (max-width: 665px) 100vw, 665px\" \/><\/a><\/p>\n<p>At the end of the process, we want the NAME, TYPE, ANSI and USPS columns for each state. The workbook query should be named &#8220;Postal Codes&#8221; and the worksheet should be named &#8220;State List&#8221;.  Please note, we have eleven island like locations in the data for a total of 69 rows.<\/p>\n<p><a href=\"https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A07-power-query-saved-script-for-later-use.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A07-power-query-saved-script-for-later-use-1024x611.jpg\" alt=\"A07-power-query-saved-script-for-later-use\" width=\"665\" height=\"396\" class=\"aligncenter size-large wp-image-7098\" srcset=\"https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A07-power-query-saved-script-for-later-use-1024x611.jpg 1024w, https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A07-power-query-saved-script-for-later-use-300x179.jpg 300w, https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A07-power-query-saved-script-for-later-use.jpg 1336w\" sizes=\"auto, (max-width: 665px) 100vw, 665px\" \/><\/a><\/p>\n<p>We can edit the saved query and filter out these rows. The resulting data set has 59 rows.<\/p>\n<p><a href=\"https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A08-power-query-update-save-n-close-less-data.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A08-power-query-update-save-n-close-less-data-1024x612.jpg\" alt=\"A08-power-query-update-save-n-close-less-data\" width=\"665\" height=\"397\" class=\"aligncenter size-large wp-image-7099\" srcset=\"https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A08-power-query-update-save-n-close-less-data-1024x612.jpg 1024w, https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A08-power-query-update-save-n-close-less-data-300x179.jpg 300w, https:\/\/craftydba.com\/wp-content\/uploads\/2014\/03\/A08-power-query-update-save-n-close-less-data.jpg 1339w\" sizes=\"auto, (max-width: 665px) 100vw, 665px\" \/><\/a><\/p>\n<p>In summary, the Power Query tool allows a novice to put together a bunch of transformations (steps) into a package called a workbook query. These steps can be replayed to manually load data on a whim. The destination location of the information, selected by the user, can be either a worksheet or the xvelocity data model. <\/p>\n<p>With the demand of business intelligence rising and the number of students graduating with a Computer Science degree <a href=\"http:\/\/www.informationweek.com\/it-strategy\/us-tech-worker-shortage-looms-study-warns\/d\/d-id\/1104496\">declining<\/a>, I can see the tool become popular for departments that need to get things done with a limited amount of help from IT.<\/p>\n<p>In upcoming articles, I will be going over each section of the ribbon. Next time, I will talk about why Power Query is very flexible given the number of import options.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In recent months, there has been a big push for self service business intelligence tools by Microsoft. The center of this universe is Microsoft Excel, a common application used by the typical data analyst. The following four products started off as add-ins for Excel. Now, some of them are a integral part of MS Office 2013. Power Query Power Pivot Power View Power Map It is not surprising that these four business intelligence products have an offering in Office 365. I really like office 365 as a platform to share&hellip;<\/p>\n","protected":false},"author":1,"featured_media":7070,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1042],"tags":[15,1044,1043,1047,1045,1046],"class_list":["post-7068","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-power-query","tag-john-f-miner-iii","tag-online-search","tag-power-query","tag-saved-steps","tag-self-service-etl","tag-workbook-query"],"_links":{"self":[{"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/posts\/7068","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7068"}],"version-history":[{"count":0,"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/posts\/7068\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/media\/7070"}],"wp:attachment":[{"href":"https:\/\/craftydba.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7068"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7068"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7068"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}