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

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.

主站蜘蛛池模板: 得荣县| 射洪县| 淮滨县| 新竹市| 临漳县| 辽中县| 丹巴县| 清水河县| 德阳市| 蓝田县| 浦北县| 新河县| 祁连县| 师宗县| 如东县| 象山县| 繁峙县| 抚顺市| 西华县| 津南区| 正阳县| 无极县| 南江县| 秦安县| 宣化县| 眉山市| 白玉县| 双峰县| 岳阳市| 惠东县| 盘山县| 麻阳| 深州市| 昭苏县| 涞水县| 凤山市| 张家口市| 前郭尔| 项城市| 渭源县| 敦煌市|