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

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.

主站蜘蛛池模板: 长白| 织金县| 明水县| 华宁县| 曲松县| 长春市| 共和县| 波密县| 普安县| 新邵县| 抚顺县| 布尔津县| 天镇县| 卢湾区| 买车| 平果县| 鄂伦春自治旗| 仙居县| 舟曲县| 罗田县| 迭部县| 保康县| 崇信县| 东至县| 类乌齐县| 运城市| 九江市| 西安市| 德安县| 板桥市| 彰武县| 横峰县| 丹阳市| 金堂县| 安西县| 宜川县| 通城县| 花垣县| 玉溪市| 公安县| 静安区|