Sunteți pe pagina 1din 23

RR I-TEC,,#209,Ni lagiri Block, Adithya Enclave @8801408841, 8790998182

Practice 8-1: Creating Dimension Hierarchies


Goal To create dimensions to introduce hierarchies into the business model
Scenario Dimensions are metadata objects that allow you to introduce hierarchies
into a business model. The dimensions and hierarchies remain hidden to
users, but they enable Oracle BI Server to provide useful calculations. You
need to implement three dimensions for ABC: Product, Customer, and
Period. Creating dimensions and hierarchies allows you to build level-based
measures, to define aggregation rules that vary by dimension, to provide
drill down on charts and tables in Answers and dashboards, and to describe
the content of aggregate sources.
Outcome In the Business Model and Mapping layer, there are ProductsDim,
CustomersDim, and PeriodsDim dimension objects.
Time 2025 minutes
Instructions
1. Return to the ABC repository, which should still be open in online mode.
2. In order to create a dimension hierarchy, you need to know the levels in the
hierarchy, the columns that uniquely define each level, and the distinct values for
each level. In this step, you identify these for the product dimension.
a. The business requirements determine the levels. In the case of the product
hierarchy for ABC, the levels are (from top to bottom): Type, Subtype, Generic,
and Specific.
b. Typically, a database administrator provides you the columns that define each
level. In ABCs case, the columns are:
Level Column on D1_PRODUCTS table that defines the level
Type TYPECODE
Subtype SUBTYPECODE
Generic GENERICDESCRIPTION
Specific SPECIFICDESCRIPTIN
c. In the Physical layer, navigate to D1_PRODUCTS.TYPECODE. Note that there
are 22 rows for the TYPECODE column. (If the row count is not visible, run
Update Row Count). This is the manual method to determine the number of
elements at each level of a hierarchy. You update row counts and then use the
row count information to set the number of elements at each level in a
RR I-TEC,,#209,Ni lagiri Block, Adithya Enclave @8801408841, 8790998182

dimension hierarchy. In a later step, you learn how to use an automated method
to determine the number of elements at each level.
d. Confirm the row counts for the other columns in D1_PRODUCTS.
Level Column on D1_PRODUCTS table that defines the level Row Count
Subtype SUBTYPECODE 159
Generic GENERICDESCRIPTION 186
Specific SPECIFICDESCRIPTIN 192
3. In this step, you create a dimension object to represent the hierarchy of products.
a. In the Business Model and Mapping layer, right-click SupplierSales and select
New Object > Dimension. The Dimension dialog box opens.
b. In the Name field, enter ProductsDim.
c. Click OK. The new dimension appears in the Business Model and Mapping
layer. Note the three-arrow icon.
4. In this step, you add the parent level of the hierarchy.
a. Right-click the ProductsDim dimension and select New Object > Logical
Level.
b. In the Name field, enter TotalProduct.
c. Because this level represents the grand total for products, select the Grand total
level check box. Note that when you do this, the Supports rollup to higher
level of aggregation field is grayed out and protected.
d. Note that the Number of elements at this level field has the value of 1. The
TotalProduct level has only one element (the grand total). Therefore, 1 is the
appropriate value for this level and cannot be changed.
e. Click OK. The new level appears as a child of the ProductsDim dimension.
5. Add the child levels of the hierarchy.
a. Right-click the TotalProduct level and select New Object > Child Level.
b. In the Name field, enter Type.
c. In the Number of elements at this level field, enter 22. Recall that this is the
value you determined in an earlier step. This number does not have to be exact.
The ratio from one level to the next is more important than the absolute number.
These numbers only affect which aggregate source is used (optimization, not
correctness of queries).
d. Ensure that Supports rollup to higher level of aggregation is selected. This
field is selected because if data is stored at the Type level, it can be aggregated
to produce the total for its parent level without double counting or leaving
anything out. There are some hierarchies where certain levels might not include
all the elements of the dimension.
e. Click OK. The Type level appears as a child of the TotalProduct level.
f. Repeat the above steps to add further child levels:
Name Number of elements at this level
RR I-TEC,,#209,Ni lagiri Block, Adithya Enclave @8801408841, 8790998182

Subtype 159
Generic 186
Specific 192
g. Ensure that your results appear as follows:

6. In this step, you specify which columns from the logical dimension table are
associated with which levels in the dimension hierarchy, starting from top to
bottom. Here are some guidelines for associating columns with levels:
Not all columns in the dimension table need to be associated explicitly
with a level; the ones that are not will be associated with the lowest level
implicitly.
No columns can be associated with more than one level (although it may
be part of the level key of a lower level).
If a column pertains to more than one level, associate it with the highest
level it belongs to.
No level except the Grand Total level can exist without at least one
column being associated with it.
The Detail level (lowest level) must have the column that is the logical key
of the dimension table associated with it and it must be the key for that
level.
a. In the Business Model and Mapping layer, expand the Products table, select
the Type column, and drag it up to the Type level.
b. Drag the logical column Type Code onto the Type level. Check your results:

c. Continue dragging logical columns from the Pr oduct s table to the
ProductsDim levels:
Logical Column Level
Subtype Subtype
RR I-TEC,,#209,Ni lagiri Block, Adithya Enclave @8801408841, 8790998182

SubtypeCode Subtype
Generic Generi c
Specific Specifi c
ProductKey Specifi c
d. Check your results:

Any column not associated explicitly with a level is associated implicitly with
the detail level. In this example, Package Weight and Supplier (among others)
are by default associated with the Specific level. The logical dimension table
key column, Pr oduct Key in this example, must be associated explicitly with
the lowest level.
e. Double-click the Type column in the Products logical table. The Logical
Column dialog box opens.
f. Click the Levels tab. This tab identifies the dimensions and logical levels
associated with this logical column. These values were set when you dragged
the column onto the ProductsDim dimension hierarchy.
g. Click the drop-down list for the Type logical level. Note that this is another
method for associating logical columns with dimensions and logical levels. You
use this method later in the next practice. Leave the logical level set to Type.
h. Click Cancel to closes the Logical Column dialog box.
7. In this step, you specify the level keys for the Type level in the hierarchy. The
level key defines the unique elements in each logical level. Each level key can
consist of one or more columns at this level (or may include columns at a higher
level). When you pick a column to represent a level key, you are saying that the
values of all columns associated with the level are dependent on the value of the
level key column. If you know the value of the level key column, you can
determine the values of the other columns.
a. In ProductsDim, double-click the Type level. The Logical Level properties
dialog box opens.
b. Click the Keys tab.
c. Click the New button. The Logical Level Key dialog box opens.
d. Select the Type check box.
RR I-TEC,,#209,Ni lagiri Block, Adithya Enclave @8801408841, 8790998182

e. Ensure that the Use for drilldown check box is selected. (Use for drilldown is
explained in the next step.)
f. Click OK. The attribute displays a key icon.
g. Click the New button again.
h. Select the Type Code check box.
i. Deselect the Use for drilldown check box.
j. Click OK.
k. Click OK.
l. Both level columns now display with key icons.
8. In this step, you set the level keys for the Subtype level using a different method.
a. In ProductsDim, right-click the Subtype column (not the level) and select
New Logical Level Key.
b. Ensure that the Subtype check box is selected.
c. Ensure that the Use for drilldown check box is selected.
d. Click OK.
e. Right-click the Subtype Code column and select New Logical Level Key.
f. Ensure that the Subtype Code check box is selected.
g. Deselect the Use for drilldown check box.
h. Click OK. Subtype is selected for drilldown and Subtype Code is not.
Later, when a user drills down in Answers or a dashboard, the default drill is to
the level key that has Use for drilldown checked in the next lowest level. Based
on this example, when a user drills down from the Type level (the next highest
level), the default is to drill down to the Subt ype column, not the Subt ype
Code column.
9. Continue specifying the following level keys for the remaining levels:
Dimensional Level Key Use for drilldown
Generic Generic Yes
Specific Specific Yes
Specific ProductKey No
RR I-TEC,,#209,Ni lagiri Block, Adithya Enclave @8801408841, 8790998182

10. Check your final results:

11. In this step, you use another method to create the customer dimension and levels.
a. Right-click the Customers logical table and select Create Dimension. A new
dimension called CustomersDim is created with two levels, Customers Total
and Customers Detail. The Customers Detail level is populated with all
columns from the Cust omer s logical dimension table.

b. Double-click the Customer Detail level, click the General tab, and note that
the number of elements at this level is set to 136. The number was inherited
automatically from Customer Key when the dimension hierarchy was created.
c. Click OK to close the Logical Level dialog box.
d. Right-click the Customer Detail level and select New Object > Parent Level.
e. Name the parent level SalesRep, set the number of elements to 34, and click
OK.
f. Create a District level as a parent of SalesRep, set the number of elements
to 12, and click OK.
g. Create a Region level as a parent of District, set the number of elements
to 3, and click OK.
RR I-TEC,,#209,Ni lagiri Block, Adithya Enclave @8801408841, 8790998182

h. Double-click the Customers Total level, ensure that it is set as the grand total
level and the number of elements is set to 1, and click OK.
i. Check your work:

j. Add columns to the hierarchy by dragging columns from the Customers Detail
level (not the Cust omer s table) to the other CustomersDim hierarchy levels.
This is a useful method when business models are large. It eliminates the need
to scroll to locate columns.
Column Level
Region Regi on
District District
Sales Rep SalesRep
k. Create the following keys for each level.
Level Key Use for drilldown
Regi on Region Yes
Distri ct District Yes
SalesRep Sales Rep Yes
Customers Detail Customer Yes
l. In the Customers Detail level, deselect Use for drilldown for Customer Key
(Customers Detail_Key).
RR I-TEC,,#209,Ni lagiri Block, Adithya Enclave @8801408841, 8790998182

m. Check your work:

n. Check in changes.
o. Click Yes to check consistency before creating more dimensions. If there are
any errors or warnings, fix them before continuing.
p. If there are no errors or warnings, close the Consistency Check Manager.
q. Save the repository.
12. In this step, you can use either of the two methods described in the previous steps
to create the Periods dimension.
a. Create a dimension hierarchy called PeriodsDim based on the Per i ods
logical dimension table.
b. Create the levels within PeriodsDim:
Name Grand
Total
Level
Supports rollup
to higher level
of aggregation
Number of
elements at
this level
TotalPeriod Yes Protected 1
Year No Yes 2
Quarter No Yes 6
Month No Yes 16
Day No Yes 474
13. There is no logical column you can associate with the Quarter level, so you need
to create one and map it to the MONTH_I N_YEAR column with a formula using a
CASE statement.
a. Double-click the D1_CALENDAR2 logical source table for the Per i ods
logical table.
b. Click the Column Mapping tab.
c. Click the New column button.
RR I-TEC,,#209,Ni lagiri Block, Adithya Enclave @8801408841, 8790998182

d. Name the column Quarter and click OK.
e. Make sure Show unmapped columns is selected.
f. Open the Expression Builder for the Quarter column.
g. Use fully qualified column names and build the following formula. Or, you can
copy and paste this formula from the Quarter.txt file in D: \ Labs.

CASE WHEN "ORCL".""."SUPPLIER2"."D1_CALENDAR2"."MONTH_IN_YEAR"
< 4 THEN 1 WHEN
"ORCL".""."SUPPLIER2"."D1_CALENDAR2"."MONTH_IN_YEAR" < 7 THEN 2
WHEN "ORCL".""."SUPPLIER2"."D1_CALENDAR2"."MONTH_IN_YEAR" < 10
THEN 3
ELSE 4 END

h. Click OK to close the Expression Builder. The expression is displayed in the
Expression field in the Logical Table Source dialog box.
i. Click OK to close the Logical Table Source dialog box.
14. Add columns to the hierarchy by dragging columns to the PeriodsDim hierarchy
levels:
Logical Column Level
Year Year
Quarter Quarter
Month Month
MonthCode Month
Month in Year Month
Day Day
Date Day
15. Create the keys for each child level in the PeriodsDim dimension. Note that
additional configuration of the key for the Quarter level is completed in a
subsequent step.
Level Key Use for drilldown
Year Year Yes
Month Month Yes
Month MonthCode No
Quarter Quarter Yes
Day Day Yes
16. Set MonthCode as the primary level key for the Month level.
a. Double-click the Month level.
b. Click the Keys tab.
c. In the Primary Key drop-down list, select MonthCode.
d. Click OK.
RR I-TEC,,#209,Ni lagiri Block, Adithya Enclave @8801408841, 8790998182

17. Setting the key for Quarter involves an additional step. Quarters (1, 2, 3, 4) occur
each year. However, these numbers do not uniquely identify a quarter, except
when combined with Year. Therefore, you need to make Year part of the Quarter
level.
a. Double-click the Quarter level in PeriodsDim.
b. Click the Keys tab.
c. Select the Quarter key.
d. Click the Edit button.
e. Click the Add Button.
f. In the Browse dialog box, expand the Periods logical table.
g. Select Year and click OK.
h. Click OK to close the Logical Level Key dialog box.
i. Click OK to close the Logical Level dialog box.
j. Check your work. It should look similar to the following screenshot. Your
results may vary depending on which method you used to build the hierarchy.

k. Drag the Quarter logical column from the Periods logical table to the Periods
presentation table in the SupplierSales presentation catalog to make it available
for queries in Answers.
18. Check in changes.
19. Check consistency.
20. Fix any consistency errors or warnings before proceeding. If there are no errors or
warnings, close the Consistency Check Manager.
21. Save the repository.
22. Open Answers and check your work:
a. Return to Answers.
b. Reload server metadata.
RR I-TEC,,#209,Ni lagiri Block, Adithya Enclave @8801408841, 8790998182

c. Create the following request:

d. Click Results.
e. Drill down on 1998 and ensure that you can see dollars data by quarter.
f. Drill down on any quarter and ensure that you can see dollars data by month.
g. Drill down on any month and ensure that you can see dollars data by day.
23. Leave Answers open.
24. Leave the Administration Tool open for the next practice.
RR I-TEC,,#209,Ni lagiri Block, Adithya Enclave @8801408841, 8790998182

Practice 8-2: Creating Level-Based Measures
Goal To create level-based measures
Scenario Now that you have created dimension hierarchies with levels, you want to use
them to implement level-based measures that calculate total dollars at various
levels.
Time 2025 minutes

Instructions
1. Return to the ABC repository, which should still be open in online mode.
2. In this step, you create new logical fact columns to represent the product level
totals based on existing fact columns.
a. In the Business Model and Mapping layer, right-click the SalesFacts table and
select New Object > Logical Column.
b. In the Name field, enter ProductTotalDollars.
c. Select the Use existing logical columns as the source check box.
d. Open the Expression Builder.
e. In the Expression Builder, add Logical Tables >SalesFacts >Dollars to the
expression. Recall that the Dollars column has a default aggregation rule of
Sum.
f. Click OK.
g. Click the Levels tab.
h. For the ProductsDim, select TotalProduct from the Level drop-down list to
specify that this measure should be calculated at the grand total level in the
product hierarchy.
i. Click OK. Note that setting the level causes the measure to automatically
appear in the ProductsDim dimension.

j. Repeat the steps to create a second level-based measure:
Name Dimension Level
ProductTypeDollars ProductsDim Type
RR I-TEC,,#209,Ni lagiri Block, Adithya Enclave @8801408841, 8790998182

k. Check your final results for the Product dimension:

3. Expose the new columns to users by dragging ProductTotalDollars and
ProductTypeDollars from the SalesFacts logical table to the SalesFacts
presentation table in the SupplierSales catalog in the Presentation layer.
4. Check in changes.
5. Check consistency. Fix any errors or warnings before proceeding.
6. If there are no errors or warnings, close the Consistency Check Manager.
7. Save the repository.
8. Test your results.
a. Return to Answers
b. Reload server metadata.
c. Create the following request:

d. For the Pr oduct TypeDol l ar s column, click the Column Properties
button, then click the Data Format tab, override the default data format, and set
to Currency, $, Decimal Places = 2, Use 1000s Separator.
RR I-TEC,,#209,Ni lagiri Block, Adithya Enclave @8801408841, 8790998182

e. Click Save > as the system-wide default for
SalesFacts.ProductTypeDollars.

RR I-TEC,,#209,Ni lagiri Block, Adithya Enclave @8801408841, 8790998182

f. Click Results. Note that ProductTypeDollars returns dollars grouped by Type
when the query is at a different level than Type; Generic in this example.

g. Drill down on a value in the Generic column. Based on how you constructed
the hierarchy in the business model, if you drill down on a value in the Generic
column, Answers drills down to the Specific column by default.

9. Leave Answers open.
RR I-TEC,,#209,Ni lagiri Block, Adithya Enclave @8801408841, 8790998182

RR I-TEC,,#209,Ni lagiri Block, Adithya Enclave @8801408841, 8790998182

Practice 8-3: Creating Share and Rank Measures
Goals To create share and rank measures
Scenario Now that you have created level-based measures, you use them to create a
share measure for products. You also create a rank measure for dollars.
Time 1530 minutes
Instructions
1. Return to the ABC repository, which should still be open in online mode.
2. Create a new share measure referencing existing logical columns.
a. In the Business Model and Mapping layer, right-click SalesFacts and select
New Object > Logical Column.
b. Name the logical column ProductShare.
c. Select the Use existing logical columns as the source check box.
d. Open the Expression Builder.
e. In the left pane, select the Functions folder.
f. In the middle pane, select Mathematic Functions.
g. In the right pane, select Round.
h. Click Insert. The function appears in the edit box.
i. Click SourceNumber.
j. Enter 100* followed by a space.
k. Select Logical Tables >SalesFacts > Dollars.
l. Click Insert.
m. Using the toolbar, click the Division button. Another set of angle brackets
appears, <<expr>>.
n. Click <<expr>>.
o. Select Logical Tables > SalesFacts > ProductTotalDollars. Recall that this
is the total measure for the hierarchy.
p. Double-click ProductTotalDollars or click Insert.
q. Click between the last set of angle brackets, <<Digits>>, and enter 1. This
represents the number of digits of precision with which to round the integer.
r. Check your work:

RR I-TEC,,#209,Ni lagiri Block, Adithya Enclave @8801408841, 8790998182

This share measure will allow you to run a query in Answers to show how
sales of a specific product compares to overall sales for all products.
s. Click OK to close the Expression Builder.
t. Click OK to close the Logical Column properties dialog box.
u. The ProductShare logical column is added to the business model.
3. Create a new rank measure referencing existing logical columns.
a. In the Business Model and Mapping layer, right-click the SalesFacts table and
select New Object > Logical Column.
b. In the Name field, enter RankDollars.
c. Select the Use existing logical columns as the source check box.
d. Open the Expression Builder.
e. Select Functions >Display Functions >Rank.
f. Double-click Rank or click Insert.
g. Click <<numExpr>>.
h. Select Logical Tables >SalesFacts >Dollars.
i. Click Insert.

j. Click OK to close the Expression Builder.
k. Check your work:

l. Click OK to close the Logical Column dialog box.
m. RankDollars is added to the business model.
RR I-TEC,,#209,Ni lagiri Block, Adithya Enclave @8801408841, 8790998182

4. Add the ProductShare and RankDollars measures to the Presentation layer by
dragging them to the SalesFacts table in the SupplierSales catalog.
5. Check in changes.
6. Check consistency. If there are errors or warnings, correct them before you
proceed.
7. If there are no errors or warnings, close the Consistency Check Manager.
8. Save the repository.
9. Test your results.
a. Return to Answers
b. Reload server metadata.
c. Create the following query:

d. For the RankDollars column, click the Order By button once to sort the
results in ascending order.
e. For the ProductShare column, click the Column Properties button, then
the Data Format tab, override the default data format, and set to Percentage
with Decimal Places = 2.
f. Click Save > as the system-wide default for SalesFacts.ProductShare.
g. Click the Results tab:

The results show total dollars for each product, the percent of total sales for
each product, and how each product ranks in total sales.
h. Create a similar query to view results for Products.Type, SalesFacts.Dollars,
SalesFacts.Product Share, and SalesFacts.Rank Dollars.
RR I-TEC,,#209,Ni lagiri Block, Adithya Enclave @8801408841, 8790998182


The results show total dollars for each product type, the percent of total sales
for each product type, and how each product type ranks in total sales.
10. Leave Answers open.
RR I-TEC,,#209,Ni lagiri Block, Adithya Enclave @8801408841, 8790998182

RR I-TEC,,#209,Ni lagiri Block, Adithya Enclave @8801408841, 8790998182

Practice 8-4: Creating Dimension-Specific
Aggregation Rules
Goal To create a measure with dimension-specific aggregation rules
Scenario ABC wants a measure called AvgDailyDollars, which sums dollar amounts
over the Customer and Product dimensions and divides by the number of days
in the Period dimension. This measure can be used to compare the average
daily dollar amount from month-to-month when the number of order days in
each month varies.
Outcome A new measure called AvgDailyDollars with dimension-specific aggregation
rules
Time 510 minutes
Instructions
1. Return to the ABC repository, which should still be open in online mode.
2. Create a new measure with dimension-specific aggregation rules.
a. In the Business Model and Mapping layer, right-click SalesFacts and select
New Object > Logical Column.
b. Name the logical column AvgDailyDollars.
c. Click the Data Type tab.
d. If necessary, select Show all logical sources.
e. Double-click the D1_ORDERS2 logical table source.
f. Click the Column Mapping tab.
g. Make sure that Show unmapped columns is selected.
h. Map AvgDailyDollars to the ACTLEXTND (dollars) physical column.
i. Click OK to close the Logical Table Source dialog box.
j. Click the Aggregation tab.
k. Select Based on dimensions.
l. In the Browse dialog box, select the PeriodsDim dimension and click OK.
m. In the Formula field, select the AVG aggregation rule from the drop-down
list.
n. Click the New button.
o. Select Other and click OK.
RR I-TEC,,#209,Ni lagiri Block, Adithya Enclave @8801408841, 8790998182

p. Select the SUM aggregation rule for Other.
q. With Other selected in the Dimension column, use the Up button to change
the aggregation rule order.

r. Click OK.
s. Drag the AvgDailyDollars measure to the SalesFact presentation table.
3. Check in changes.
4. Check Global Consistency. Fix errors and warnings before you proceed.
5. Close the Consistency Check Manager.
6. Save the repository.
7. Test your work.
a. Return to Answers, reload server metadata, and create the following request
and filter.
Hint: Add Month Code to the query, create the filter, and then remove Month
Code from the query.



b. Check your results:

c. Considering that there are 25 order days in the first month of 1999, use the
Windows calculator to check that the results of the query are correct for
average daily dollars.

S-ar putea să vă placă și