官术网_书友最值得收藏!

Time for action – creating a Named Calculation

In this exercise, we will create a new calculated column in the DSV for the full name because the customer dimension only contains the first name and last name separately. You will see how we can use T-SQL commands to create a Named Calculation. Perform the following steps to create a Named Calculation.

  1. Go to the Adventure Works DW2012 DSV designer.
  2. In the Customer dimension, you can see that there are three name columns as First name, Middle name, and Last name, but there is no full name. We want to have the full name shown as the main customer attribute of the customer dimension in the cube. So, we will create a column in DSV for that.
  3. Right-click on DimCustomer and select New Named Calculation.
  4. Set the column name as Full Name, and write the following code in the expression area:
    FirstName+' '+ISNULL(MiddleName+' ','')+LastName
  5. Click on OK and you will see the new column added to the table. Right-click on DimCustomer and select Explore Data. Some sample data rows from the Customer table will be shown in another window and you can also see the Full Name column populated at the end of the column's list as well.
  6. Go to the Customer Dimension Designer, select the Customer Key attribute, and change the NameColumn to Full Name from DimCustomer. Also, rename the Customer key to Customer.
  7. Browse the Customer dimension (after deploying and processing), and you will see that the full name of the customer appears as Customer Values in the browser.

What just happened?

Named Calculations are very useful when you want to add calculated columns to the underlying database, but for some reason, you cannot do that in the database. For example, your user account only has read-only permissions on the database. In such cases, you can benefit by creating Named Calculations.

As you've seen in this example, Named Calculations are created based on the expression area. The language of the expression is based on the underlying database. This means that if the underlying database is an Oracle database, you can use functions such as rownum or decode, which work in an Oracle environment. If the underlying database is SQL Server, you can use functions and T-SQL codes that are acceptable in that SQL Server version.

You also saw how to check the result of the execution of Named Calculations with the Explore Data option. You can also change the sampling settings for the explored data.

主站蜘蛛池模板: 丁青县| 江山市| 东源县| 醴陵市| 平定县| 兖州市| 永靖县| 平山县| 张家港市| 旺苍县| 磴口县| 丰台区| 肥乡县| 辽宁省| 资兴市| 宜城市| 瑞安市| 吉林省| 玉田县| 长白| 玉田县| 宜章县| 布尔津县| 合水县| 中卫市| 卢龙县| 安多县| 双桥区| 仙居县| 延安市| 长寿区| 津南区| 班玛县| 镇江市| 饶河县| 黄石市| 襄城县| 忻城县| 台北市| 泸定县| 扎囊县|