Skip to content

Get the most out of MSSQL !

Consultant & Trainer for all things MSSQL

  • Home
  • Company
  • Business Intelligence
  • Simply Better Business

SSAS: – Defining a measure

Posted on July 25, 2014March 20, 2021 by jayanth.kurup

Now that the dimension has been defined we need to add a measure to our cube in order to be able to answer the question “What is distribution of sales by card type so that we can partner with the best provider to give our customers discounts”

We already have a dimension which will help use analyse the credit card types , but we now need to have a way of identifying the count of orders , in order to do this we need to revisit our original design. We started out by creating a data source view that contained 2 different tables with order information the first one being the order header and the second one being the order detail. The nature of the order header defines that payments are done against the order and not the individual line items. Imagine paying for each item one at a time at the checkout counter. All the items together belong to the same order so it makes sense for us to group data from the different line items up to order level and then simply have an order level grand total.

However, we have replaced the order header and order line items tables with a named query which joins the order header to the order line by ordered in order to have a single fact table. This means that while we had one row per order header in the previous scenario we not have the order header repeated as many times as there are line items within the order. This is not an ideal cube design and was implemented only to show that use of named queries when de-normalizing. Let’s leave it as it is for now. Now that we are aware of the quirk on our data we need to account for it when creating the measure.

Open the democube project and select the Cube name from the measures pane on the top left window of the cube designer. Right click and select New Measure.

The below windows will appear , it will default to the table that appears first alphabetically so make sure to select the SalesOrderDetails named query as the Source table in the second drop down list. Here you will see that not all columns are visible initially, this is because a measure is usually something that can be aggregated i.e. summed, counted, averaged etc. Text values do not fit into this description and so SSAS assumes these columns are not measures. However as mentioned earlier in our case we need to be able to count the distinct number of Orderid in our fact table SalesOrderdetails in order to know how many orders were place using a particular credit card. So we select the check box at the bottom of the screen called Show all Columns, at this point all columns within the named query Sales Order details are listed and we can now select the Sales OrderID. . A key thing to remember now is that we do not want to count the Sales OrderID as it is, because for an order with 10 line items we will have the order id repeated 10 times. So in this case we need to count the number of distinct occurrence of the Sales order id so in the Usage drop down list we select the option for distinct count.

Press OK once you’re done and we will see that the measure group (a broad classifier for similar measures which usually originate from the same table) with the single measure called Sales OrderId Distinct Count. At this point we have created our measure. It is a bit long so I am going to rename it to Cnt_SalesOrderId.

Simply select the measure and Press F2 on the keyboard to rename the measure.

Please Consider Subscribing

Subscribe

CategoriesDatabasesTagsaccount, administration, age, AI, alphabet, Analysis Services, answer, app, average, AWS, Azure, azurewebsites, Bangalore, Bengaluru, BigData, bit, BLR, board, box, Business Intelligence, CaL, call, card, card type, case, cause, check, Cloud, Cnt_SalesOrderId, column, Consultant, Consulting, Corporate, count, CREATE, cred, credit card, credit card type, cube, cube design, cube designer, customer, Data, data source, data source view, database, defined, democube project, description, designer, detail, development, different table, dimension, discount, distribution, drop, Enabled Business Solutions, enabledbusiness, etc., expert, fact, fact table, fine, form, format, FYI, gate, grand total, group, head, help, idea, index, India, individual, info, information, int, item, Jayanth, key, key thing, Kurup, level, lie, line, line item, mean, measure, measure group, member, Migration, ML, ms sql server, MSBI, MSSQL, MYSQL, name, nature, need, network, New Measure, number, option, Oracle, order detail, order header, order line, pane, part, partner, payment, place, png, point, power pivot, Power Query, PowerApps, PowerBI, Powershell, pre, Press, project, provider, Python, Query, question, RDBMS, red, Remote, road, row, sale, sales order detail, Sales order id, SalesOrderDetail, SalesOrderDetails, scenario, script, sec, second, security, SELECT, sense, show, sign, site, source, SQL 2000, SQL 2005, SQL 2008, sql 2008 r2, sql 2012, SQL 2014, SQL 2016, SQL 2017, SQl 2019, SSAS, SSIS, SSMS, SSRS, star, start, SUM, T-SQL, tab, Tables, text, thing, tools, total, trainer, Transact, tuning, type, Upgrade, uploads, usage, value, VALUES, Very large database, view, Virtual, virtual machine, VISIBLE, visit, visual studio, VM, war, Web, website, Websites, window, windows

jayanth.kurup

This post was written by Jayanth Kurup. A Microsoft SQL Server Consultant and Trainer based out of Bangalore, India. Jayanth has been working on MS SQL Server for over 15 years. He is a performance tuning and Business Intelligence expert. Having worked with companies like Microsoft, DELL, Wells Fargo, Thomson Reuters and many other fortune 100 companies. Some other technologies Jayanth works on include Microsoft Azure, PowerBI, Python and AWS. When he isn’t consulting or training, Jayanth like to travel, paint and read. He is also very active in social causes and the founder of Enabled Business Solutions. Visit his company by clicking the link in the menu or email him directly.

Post navigation

PreviousPrevious post: SSAS: – Define translation
NextNext post: SSAS: browsing the cube

The Latest

  • Monty Hall Simulation using T-SQL April 5, 2022
  • Query to quickly profile a column February 7, 2022
  • Outlook 2019 keeps asking for password multiple times December 9, 2021
  • Part 2:- Learning T SQL for beginners – Datatypes September 28, 2021
  • Part 1:- Learning T SQL for beginners- SQL, Tables and Nulls September 27, 2021
  • Query to find execution time of Jobs July 28, 2021
  • A simple script to decapitalize Column names July 19, 2021
  • My personal side effects with Covishield June 27, 2021
  • Setting up and Configuring CUDA, CUDNN and PYTorch for Python Machine Learning. June 3, 2021
  • keras.utils.generic_utils’ has no attribute ‘populate_dict_with_module_objects May 30, 2021

Find By Category

  • Azure
  • Databases
  • Events
  • Performance Tuning
  • PowerBI
  • Uncategorized
  • Website Design

Archive

  • April 2022 (1)
  • February 2022 (1)
  • December 2021 (1)
  • September 2021 (2)
  • July 2021 (2)
  • June 2021 (2)
  • May 2021 (2)
  • April 2021 (5)
  • March 2021 (10)
  • January 2021 (2)
  • November 2020 (2)
  • October 2020 (3)
  • September 2020 (4)
  • August 2020 (6)
  • July 2020 (1)
  • June 2020 (32)
  • May 2020 (18)
  • April 2020 (2)
  • March 2020 (4)
  • February 2020 (5)
  • January 2020 (1)
  • December 2019 (1)
  • November 2019 (14)
  • October 2019 (3)
  • September 2019 (1)
  • July 2019 (3)
  • June 2019 (2)
  • May 2019 (1)
  • April 2019 (2)
  • March 2019 (1)
  • January 2019 (4)
  • December 2018 (2)
  • November 2018 (4)
  • September 2018 (6)
  • August 2018 (2)
  • July 2018 (3)
  • June 2018 (4)
  • May 2018 (1)
  • April 2018 (4)
  • March 2018 (3)
  • February 2018 (3)
  • January 2018 (1)
  • December 2017 (2)
  • November 2017 (4)
  • August 2017 (2)
  • July 2017 (5)
  • May 2017 (1)
  • March 2017 (3)
  • January 2017 (3)
  • December 2016 (2)
  • November 2016 (2)
  • October 2016 (4)
  • September 2016 (1)
  • August 2016 (1)
  • July 2016 (1)
  • June 2016 (1)
  • May 2016 (2)
  • April 2016 (1)
  • March 2016 (14)
  • February 2016 (10)
  • January 2016 (19)
  • December 2015 (3)
  • November 2015 (5)
  • October 2015 (10)
  • September 2015 (9)
  • August 2015 (16)
  • July 2015 (13)
  • June 2015 (4)
  • May 2015 (2)
  • April 2015 (2)
  • March 2015 (7)
  • February 2015 (3)
  • January 2015 (22)
  • December 2014 (1)
  • November 2014 (5)
  • October 2014 (12)
  • September 2014 (5)
  • August 2014 (7)
  • July 2014 (41)
  • June 2014 (9)
  • May 2014 (12)
  • April 2014 (32)

Members Only

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
Proudly powered by WordPress