# OBIEE 10G/11G - Level-Based Measure Calculations

A level-based measure is a column whose values are always calculated to a specific level of aggregation.

The calculation of this measure is independent of the query grain and used always the aggregation grain of the logical column.

Level-based measures allow :

• to return data at multiple levels of aggregation (the query grain and the level-based column grain) with one single query
• to create share measures (percentage), that are calculated by taking some measure and dividing it by a level-based measure. For example, you can divide salesperson revenue by regional revenue to calculate the share of the regional revenue each salesperson generates.

The new OBIEE function in 11G AGGREGATE AT can leverage the same functionality

## 3 - How to create a level based measure

To create a level based measure as the amount sold by region, you can:

• make a copy of the Amount Sold logical column
• and then
• drag the logical column into its hierarchy level
• or set the aggregation grain in the level tab of the logical column property.

## 4 - A level-based measure

### 4.1 - with a lowest query grain

With a lowest query grain, each query that requests these column will return the amount aggregated to its associated levels (in our case by region)

To obtain the good total, you have to uncheck the aggregate option : Report-Based Total (when applicable)

### 4.2 - with a higher query grain

When a query includes a level-based measure column, and the query grain is higher than the level of aggregation specific to the column, the query results return null. Note that in releases previous from 11g, results were returned for this situation, but they were not deterministic.

## 5 - Query Performed

And only ONE query is performed :

```SELECT D1.c4 AS c1,
D1.c2 AS c2,
SUM(D1.c1) OVER (partition BY D1.c4)  AS c3,
D1.c1 AS c4
FROM
(SELECT SUM(T245.AMOUNT_SOLD) AS c1,
T175.COUNTRY_NAME AS c2,
T175.COUNTRY_REGION AS c4
FROM
SH.COUNTRIES T175,
SH.CUSTOMERS T186,
SH.SALES T245
WHERE  ( T175.COUNTRY_ID = T186.COUNTRY_ID AND T175.COUNTRY_REGION = 'Europe' AND T186.CUST_ID = T245.CUST_ID )
GROUP BY T175.COUNTRY_NAME, T175.COUNTRY_REGION
) D1
ORDER BY c1, c2```

## 6 - Configuration

By default, each level of a dimension hierarchy shows both:

• dimension columns that are assigned to that level,
• and level-based measures that have been fixed at that level. If you don't want this behaviour, you can check the “Hide Level Based Measures” options (Tools/Options in the Administration Tool).

## 7 - Support

### 7.1 - The query results return null

The query results return null because the query grain is higher than the level of aggregation specific to the level-based measure column.