{"id":1774,"date":"2013-09-16T05:24:11","date_gmt":"2013-09-16T05:24:11","guid":{"rendered":"http:\/\/bicortex.com\/?p=1774"},"modified":"2016-05-02T08:51:22","modified_gmt":"2016-05-02T08:51:22","slug":"how-to-build-a-data-mart-using-microsoft-bi-stack-part-7-cube-creation-cube-deployment-and-data-validation","status":"publish","type":"post","link":"http:\/\/bicortex.com\/bicortex\/how-to-build-a-data-mart-using-microsoft-bi-stack-part-7-cube-creation-cube-deployment-and-data-validation\/","title":{"rendered":"How To Build A Data Mart Using Microsoft BI Stack Part 7 &#8211; Cube Creation, Cube Deployment and Data Validation"},"content":{"rendered":"<p style=\"text-align: justify;\">In the <a href=\"http:\/\/bicortex.com\/how-to-build-a-data-mart-using-microsoft-bi-stack-part-6-refining-ssas-data-warehouse-dimensions\/\" target=\"_blank\"><b>PREVIOUS POST<\/b><\/a> I showed you how to refine our SSAS project and went over the concepts of dimension properties and hierarchies before cube creation and deployment process can be initiated.\u00a0 In this post I would like to focus on the concepts of SSAS solution deployment and cube creation as well as go through some basic validation techniques to ensure that our data mart has correct data in it before it can be reported out of.<\/p>\n<h3 align=\"center\">Creating The SSAS Cube<\/h3>\n<p style=\"text-align: justify;\">Let\u2019s continue on with the sample SSAS project which we polished up last time. All files relevant to further develop, deploy and test this solution as well as all the code used in previous posts to this series can be found <a href=\"https:\/\/skydrive.live.com\/redir?resid=715AEF07A82832E1!46701&amp;authkey=!AN0EIyuXwwzHVvo\" target=\"_blank\"><b>HERE<\/b><\/a>. In order to browse the dimensions we must first deploy them to our SSAS database. Visual Studio uses XML files for data sources, data source views, dimensions, and cubes, and there is a hidden master file that contains all of this code. The act of building of an SSAS project checks the validity of these files and combines them into this master file. The quickest way to deploy is to it from Visual Studio environment itself, however, we must first specify the SSAS instance we would like our database to be created on. To do this, right-click on root level of the project in Solution Explorer and select Properties as per image below (Alt + Enter should also work).<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/bicortex.com\/bicortex\/wp-content\/post_content\/\/2013\/09\/Project_properties_SSAS_HTDM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1775\" src=\"http:\/\/bicortex.com\/bicortex\/wp-content\/post_content\/\/2013\/09\/Project_properties_SSAS_HTDM.png\" alt=\"Project_properties_SSAS_HTDM\" width=\"580\" height=\"416\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">Next, select Deployment option from the Configuration Properties pane and populate the Target Server and Target Database as per below.<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/bicortex.com\/bicortex\/wp-content\/post_content\/\/2013\/09\/Deployment_server_properties_SSAS_HTDM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1776\" src=\"http:\/\/bicortex.com\/bicortex\/wp-content\/post_content\/\/2013\/09\/Deployment_server_properties_SSAS_HTDM.png\" alt=\"Deployment_server_properties_SSAS_HTDM\" width=\"580\" height=\"200\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">To process individual dimension we have meticulously created and deploy the data onto our SSAS server we can right-click on each dimension individually and select Process from the options provided. This should present us with another dialog window where providing we have done correct modelling decisions we can select Run to process our dimension. In case there are errors and you cannot deploy the data onto the specified SSAS server, go through the log to establish the cause for the issues which in most cases would pertain to the connection credentials or target deployment properties.<\/p>\n<p style=\"text-align: justify;\">Finally, let\u2019s look into how to create an SSAS cube. In order to start the cube wizard, right-click on the Cubes folder under solution explorer and select New Cube \u2013 this should start the wizard which will guide us through this process and is similar to the steps taken in order to create individual dimensions. After the welcome pane is displayed, click Next and on Select Creation Method click on Use Existing Tables from the options provided. Next step prompts us to select tables used for measure groups. This window allows you to choose which fact tables will be included in the cube. In our example, we have two fact tables: one that contains the measures and one that is used as a bridge between the Authors many-to-many dimension \u2013 let\u2019s select them both and click next to continue with the wizard.\u00a0 In the next step, the wizard suggests columns and measures to use by comparing the columns\u2019 data types. For example, Author Order is recommended as a measure because it is a fact table and it has a numeric value. This simple criteria is how the wizard decides what should and should not be included. You will also notice that Fact Sales Count and Fact Titles Authors Count have been added. The wizard suggests these additional measures to provide row counts for Fact Sales and Fact Titles Authors for your convenience, in case you need totals for each. The wizard labels these as Count measures for you, but you can change the names if you prefer. Following on, we select the four previously created dimensions and in the next step give our cube a meaningful name which should conclude the wizard. On completion Visual Studio displays cube designer window as per image below.<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/bicortex.com\/bicortex\/wp-content\/post_content\/\/2013\/09\/Cube_schema_SSAS_HTDM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1777\" src=\"http:\/\/bicortex.com\/bicortex\/wp-content\/post_content\/\/2013\/09\/Cube_schema_SSAS_HTDM.png\" alt=\"Cube_schema_SSAS_HTDM\" width=\"570\" height=\"335\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">All there is left to do is to deploy the cube onto our server, configure it and test the data for any inconsistencies. The quickest way to deploy this is to right-click on the cube and select Process from the context menu provided. Once the process is completed, the following window should notify you of the process success\/failure and the steps taken during cube processing and deployment.<\/p>\n<p style=\"text-align: justify;\"><a href=\"http:\/\/bicortex.com\/bicortex\/wp-content\/post_content\/\/2013\/09\/Processing_progress_cube_SSAS_HTDM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1778\" src=\"http:\/\/bicortex.com\/bicortex\/wp-content\/post_content\/\/2013\/09\/Processing_progress_cube_SSAS_HTDM.png\" alt=\"Processing_progress_cube_SSAS_HTDM\" width=\"580\" height=\"216\" srcset=\"http:\/\/bicortex.com\/bicortex\/wp-content\/post_content\/2013\/09\/Processing_progress_cube_SSAS_HTDM.png 580w, http:\/\/bicortex.com\/bicortex\/wp-content\/post_content\/2013\/09\/Processing_progress_cube_SSAS_HTDM-300x111.png 300w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">There are other steps involved in further cube configuration which depends on the project requirements e.g. setting up translations, creating partitions, defining perspectives, adding custom calculations etc. however, given the intended purpose of this series I will not expand on those here. However, just like dimension, the cube also requires certain level of configuration input and validation so le\u2019s run through those here.<\/p>\n<p style=\"text-align: justify;\">Most of the cube configuration is done through adjusting the settings on the cube designer tabs. Each of those tabs is responsible for different cube properties. The image below shows the tabs selection for cube designer.<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/bicortex.com\/bicortex\/wp-content\/post_content\/\/2013\/09\/Cube_design_toolbar_SSAS_HTDM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1779\" src=\"http:\/\/bicortex.com\/bicortex\/wp-content\/post_content\/\/2013\/09\/Cube_design_toolbar_SSAS_HTDM.png\" alt=\"Cube_design_toolbar_SSAS_HTDM\" width=\"580\" height=\"68\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">As far as configuring the properties of each measure and dimension which constitutes the cube content, these are usually accessed through the properties window on the Cube Structure tab. If you can\u2019t see in it should be as easy as right-clicking on individual fact or dimension and selecting Properties from the context menu as per below.<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/bicortex.com\/bicortex\/wp-content\/post_content\/\/2013\/09\/Cube_attributes_properties_pane_SSAS_HTDM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1780\" src=\"http:\/\/bicortex.com\/bicortex\/wp-content\/post_content\/\/2013\/09\/Cube_attributes_properties_pane_SSAS_HTDM.png\" alt=\"Cube_attributes_properties_pane_SSAS_HTDM\" width=\"580\" height=\"320\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">To save space and leave the most procedural tasks out of this post I have put together a document which can be downloaded from <strong><a href=\"http:\/\/bicortex.com\/bicortex\/wp-content\/post_content\/\/2013\/09\/Cube_Configuration_Instructions.docx\">HERE<\/a><\/strong>. It<b> <\/b>outlines the changes necessary to be made in order to configure the cube and its properties. Alternatively, you can view and download all the necessary files for this and other posts for this series from <a href=\"https:\/\/onedrive.live.com\/redir?resid=715AEF07A82832E1!46701&amp;authkey=!AN0HYyocfqJ7vKQ&amp;ithint=folder%2c\" target=\"_blank\"><b>HERE<\/b><\/a>.<\/p>\n<h3 align=\"center\">Database vs. Cube Data Validation<\/h3>\n<p style=\"text-align: justify;\">Finally, let\u2019s superficially validate the figures in the cube versus data warehouse objects to find out if what we have put together checks out and is a valid representation of our measures and dimensions. There are many very elaborate methods of validating the data between SSAS and database objects and in this post I will cover two ways of testing to highlight the potential discrepancies. The easiest way to compare the data between what\u2019s in the cube and on the table level is to navigate to the Browser tab from the cube designer window (last tab) and drag desired measures and dimensions onto the query pane. This process is very much like building a pivot table in Excel and once the objects data is displayed and aggregated we can conveniently export the results into Excel straight from the SSAS project (version 2012 and up only) with a click of a button as per below.<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/bicortex.com\/bicortex\/wp-content\/post_content\/\/2013\/09\/Compare_cube_and_db_code_2_HTDM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1783\" src=\"http:\/\/bicortex.com\/bicortex\/wp-content\/post_content\/\/2013\/09\/Compare_cube_and_db_code_2_HTDM.png\" alt=\"Compare_cube_and_db_code_2_HTDM\" width=\"580\" height=\"410\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">In the above image I dragged SalesQuantity and NumberOfSales measures as well as Date dimension onto the query pane and SSAS automatically aggregated the data for me. In order to validate that these figures are, in fact, what we store in the database let\u2019s write a quick SQL and compare the output from both queries (even though the query can be composed by dragging and dropping measures\/dimensions onto the query pane SSAS writes MDX code in the background).<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\nUSE DW_Sample\r\nSELECT\r\nd.datename as Date,\r\nSUM(&#x5B;SalesQuantity]) as SalesQuantity,\r\nCOUNT(*) as NumberOfSales\r\nFROM &#x5B;DW_Sample].&#x5B;dbo].&#x5B;FactSales] s join DimDates d ON s.orderdatekey = d.DateKey\r\nGROUP BY d.datename\r\n<\/pre>\n<p style=\"text-align: justify;\">When executed, the figures from the database which feeds out SSAS project are identical to those stored in the cube as per image below.<\/p>\n<p style=\"text-align: justify;\"><a href=\"http:\/\/bicortex.com\/bicortex\/wp-content\/post_content\/\/2013\/09\/Compare_cube_and_db_code_1_HTDM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1785\" src=\"http:\/\/bicortex.com\/bicortex\/wp-content\/post_content\/\/2013\/09\/Compare_cube_and_db_code_1_HTDM.png\" alt=\"Compare_cube_and_db_code_1_HTDM\" width=\"580\" height=\"434\" srcset=\"http:\/\/bicortex.com\/bicortex\/wp-content\/post_content\/2013\/09\/Compare_cube_and_db_code_1_HTDM.png 580w, http:\/\/bicortex.com\/bicortex\/wp-content\/post_content\/2013\/09\/Compare_cube_and_db_code_1_HTDM-300x224.png 300w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">This method works well for small data sets but isn\u2019t very effective with large volumes of data. Another, slightly more elaborate but also much more accurate and effective way is to create a linked server to our OLAP database and execute OPENQUERY SQL statement to extract the dimensional data in a tabular fashion for further comparison. First, let\u2019s create a linked server executing the following SQL.<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\nEXEC master.dbo.sp_addlinkedserver\r\n@server = N'SQL2012_MultiDim',\r\n@srvproduct = '',\r\n@provider = N'MSOLAP',\r\n@datasrc = N'Sherlock\\sql2012_MultiDim',\r\n@catalog = N'DW_Sample_SSAS'\r\n<\/pre>\n<p style=\"text-align: justify;\">As you remember, when visually building a result set in a Browser tab in Visual Studio, SSAS also creates MDX code in the background. To access we simply click on the Design Mode button to change the interface from visual to code. If you had the desired result set already created visually, the MDX code should look similar to the one below.<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/bicortex.com\/bicortex\/wp-content\/post_content\/\/2013\/09\/Query_MDX_code_SSAS_HTDM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1786\" src=\"http:\/\/bicortex.com\/bicortex\/wp-content\/post_content\/\/2013\/09\/Query_MDX_code_SSAS_HTDM.png\" alt=\"Query_MDX_code_SSAS_HTDM\" width=\"580\" height=\"190\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">Let\u2019s copy the code and wrapping it around with an OPENQUERY SQL statement let&#8217;s bring back the results in Microsoft SQL Server Management Studio as per below.<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\nSELECT *\r\nFROM OPENQUERY\r\n(SQL2012_MultiDim,\r\n'SELECT NON EMPTY { &#x5B;Measures].&#x5B;SalesQuantity], &#x5B;Measures].&#x5B;NumberOfSales] } ON COLUMNS,\r\nNON EMPTY { (&#x5B;DimDates].&#x5B;Date].&#x5B;Date].ALLMEMBERS ) } DIMENSION PROPERTIES MEMBER_CAPTION,\r\nMEMBER_UNIQUE_NAME ON ROWS FROM &#x5B;DW_Sample_Cube]\r\nCELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR,\r\nFORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS')\r\n<\/pre>\n<p style=\"text-align: justify;\">Finally, after a little clean-up we can go ahead and compare the results between the cube and database using, for example, EXCEPT SQL statement as per the code snippet below.<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\nSELECT\r\nCAST(&quot;&#x5B;DimDates].&#x5B;Date].&#x5B;Date].&#x5B;Member_Caption]&quot; AS nvarchar (50)) AS DateName,\r\nCAST(&quot;&#x5B;Measures].&#x5B;SalesQuantity]&quot; AS int) AS SalesQuantity,\r\nCAST(&quot;&#x5B;Measures].&#x5B;NumberOfSales]&quot; AS int) AS NumberOfSales\r\nFROM OPENQUERY\r\n(SQL2012_MultiDim,\r\n'SELECT NON EMPTY { &#x5B;Measures].&#x5B;SalesQuantity], &#x5B;Measures].&#x5B;NumberOfSales] } ON COLUMNS,\r\nNON EMPTY { (&#x5B;DimDates].&#x5B;Date].&#x5B;Date].ALLMEMBERS ) } DIMENSION PROPERTIES MEMBER_CAPTION,\r\nMEMBER_UNIQUE_NAME ON ROWS FROM &#x5B;DW_Sample_Cube]\r\n')\r\n\r\nEXCEPT\r\n\r\nSELECT\r\nd.datename As DateName,\r\nSUM(&#x5B;SalesQuantity]) as SalesQuantity,\r\nCOUNT(*) as SalesCount\r\nFROM &#x5B;DW_Sample].&#x5B;dbo].&#x5B;FactSales] s\r\njoin &#x5B;DW_Sample].&#x5B;dbo].&#x5B;DimDates] d ON s.orderdatekey = d.DateKey\r\nGROUP BY d.datename\r\n<\/pre>\n<p style=\"text-align: justify;\">If, after executing, the result brings back no values, this indicates data overlap and is symptomatic of that fact that there are no differences between the cube and the database. Similarly, you can try using INTERSECT SQL command in place if EXCEPT which should provide the opposite results i.e. only return the rows with identical data.<\/p>\n<p style=\"text-align: justify;\">This concludes this post. As usual, the code used in this series as well as solution files for this SSAS project can be found and downloaded from <a href=\"https:\/\/onedrive.live.com\/redir?resid=715AEF07A82832E1!46701&amp;authkey=!AN0HYyocfqJ7vKQ&amp;ithint=folder%2c\" target=\"_blank\"><b>HERE<\/b><\/a>. In the <a href=\"http:\/\/bicortex.com\/how-to-build-a-data-mart-using-microsoft-bi-stack-part-8-creating-sample-ssrs-report\/\" target=\"_blank\"><b>NEXT ITERATION<\/b><\/a> to the series I will be building a simple SSRS (SQL Server Reporting Services) report based on our data mart.<\/p>\n<p style=\"text-align: justify;\">Please also check other posts from this series:<\/p>\n<ul>\n<li><a href=\"http:\/\/bicortex.com\/how-to-build-a-data-mart-using-microsoft-bi-stack-part-1-introduction-and-oltp-database-analysis\/\" target=\"_blank\">How To Build A Data Mart Using Microsoft BI Stack Part 1 \u2013 Introduction And OLTP Database Analysis<\/a><\/li>\n<li><a href=\"http:\/\/bicortex.com\/how-to-build-a-data-mart-using-microsoft-bi-stack-part-2-olap-database-objects-modelling\/\" target=\"_blank\">How To Build A Data Mart Using Microsoft BI Stack Part 2 \u2013 OLAP Database Objects Modelling<\/a><\/li>\n<li><a href=\"http:\/\/bicortex.com\/how-to-build-a-data-mart-using-microsoft-bi-stack-part-3-datamart-load-coding\/\" target=\"_blank\">How To Build A Data Mart Using Microsoft BI Stack Part 3 \u2013 Data Mart Load Approach And Coding<\/a><\/li>\n<li><a href=\"http:\/\/bicortex.com\/how-to-build-a-data-mart-using-microsoft-bi-stack-part-4-data-mart-load-using-ssis\/\" target=\"_blank\">How To Build A Data Mart Using Microsoft BI Stack Part 4 \u2013 Data Mart Load Using SSIS<\/a><\/li>\n<li><a href=\"http:\/\/bicortex.com\/how-to-build-a-data-mart-using-microsoft-bi-stack-part-5-ssas-project-and-dimensions-defining\/\" target=\"_blank\">How To Build A Data Mart Using Microsoft BI Stack Part 5 \u2013 Defining SSAS Project And Its Dimensions<\/a><\/li>\n<li><a href=\"http:\/\/bicortex.com\/how-to-build-a-data-mart-using-microsoft-bi-stack-part-6-refining-ssas-data-warehouse-dimensions\/\" target=\"_blank\">How To Build A Data Mart Using Microsoft BI Stack Part 6 \u2013 Refining SSAS Data Warehouse Dimensions<\/a><\/li>\n<li><a href=\"http:\/\/bicortex.com\/how-to-build-a-data-mart-using-microsoft-bi-stack-part-8-creating-sample-ssrs-report\/\" target=\"_blank\">How To Build A Data Mart Using Microsoft BI Stack Part 8 \u2013 Creating Sample SSRS Report<\/a><\/li>\n<\/ul>\n<p style=\"text-align: justify;\">All SQL code and solution files can be found and downloaded from <a href=\"https:\/\/onedrive.live.com\/redir?resid=715AEF07A82832E1!46701&amp;authkey=!AN0HYyocfqJ7vKQ&amp;ithint=folder%2c\" target=\"_blank\"><b>HERE<\/b><\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the PREVIOUS POST I showed you how to refine our SSAS project and went over the concepts of dimension properties and hierarchies before cube creation and deployment process can be initiated.\u00a0 In this post I would like to focus on the concepts of SSAS solution deployment and cube creation as well as go through [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32,5,33],"tags":[58,54],"class_list":["post-1774","post","type-post","status-publish","format-standard","hentry","category-how-tos","category-sql","category-ssas","tag-data-modelling","tag-ssas"],"aioseo_notices":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/bicortex.com\/bicortex\/wp-json\/wp\/v2\/posts\/1774","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bicortex.com\/bicortex\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bicortex.com\/bicortex\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bicortex.com\/bicortex\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/bicortex.com\/bicortex\/wp-json\/wp\/v2\/comments?post=1774"}],"version-history":[{"count":10,"href":"http:\/\/bicortex.com\/bicortex\/wp-json\/wp\/v2\/posts\/1774\/revisions"}],"predecessor-version":[{"id":2873,"href":"http:\/\/bicortex.com\/bicortex\/wp-json\/wp\/v2\/posts\/1774\/revisions\/2873"}],"wp:attachment":[{"href":"http:\/\/bicortex.com\/bicortex\/wp-json\/wp\/v2\/media?parent=1774"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bicortex.com\/bicortex\/wp-json\/wp\/v2\/categories?post=1774"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bicortex.com\/bicortex\/wp-json\/wp\/v2\/tags?post=1774"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}