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

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.

主站蜘蛛池模板: 孝感市| 平江县| 安宁市| 河北区| 天气| 景宁| 阿坝| 互助| 西盟| 南昌县| 东明县| 阜南县| 滨海县| 上饶县| 雷波县| 临泉县| 宣城市| 龙陵县| 平江县| 孟州市| 龙泉市| 星子县| 周至县| 余江县| 东台市| 九寨沟县| 清河县| 酉阳| 灵武市| 黄陵县| 拜泉县| 广宁县| 新宁县| 盐亭县| 石渠县| 怀柔区| 绥化市| 项城市| 永城市| 普宁市| 周至县|