Database Reference
In-Depth Information
Creating a calculated measure
One of the great strengths in a model is the ability to create calculated measures and
calculated columns. This recipe will cover calculated measures, and the next recipe
will discuss calculated columns. However, this is a good place to differentiate between
the two.
A good example of a calculated measure would be the sum of sales in our sample
model. In this case, we will want to slice the sum by many different values within the
model, such as date, customer, and product. A calculated measure will use these val-
ues to create a slice of references that are used to get the sum of sales.
One example of a calculated member is a formatted customer name such as Last
name, first name . In this case, you need to use the context of the row in the table
as part of the calculation because each row will use its values in the calculation. More
on calculated columns can be found in the next recipe.
In this recipe, you will learn how to create calculated measures within the model.
Getting ready
You need to have the data view of the model open. Open the Internet Sales table
and we will begin.
How to do it…
In the Internet Sales table, select the SalesAmount column. The quickest way
to add a calculated measure is by using the Aggregation button on the toolbar, which
also looks like a sum symbol. Because the most common aggregation used in analyt-
ic models is sum, it is therefore the default option. However, the drop down will create
averages, counts, distinct counts, max, and min aggregations for the selected column
as well.
1. Select the Sales Amount column, and then click on the sum symbol. This
will create a new calculated measure in the measure grid below the column. If
you click on the cell in the measure grid, you will see the DAX formula used to
create the calculation. It should be similar to the following formula:
Search WWH ::




Custom Search