Add Measures and Attributes to a Semantic Model
This topic describes how to add measures and attributes to your semantic model.
Topics:
Edit Measures and Attributes
Use the table editor to add, edit, and delete measures and attributes in your semantic model.
Specify Aggregation for Measures in Fact Tables
You can specify aggregation for a measure in a fact table. For example, you can set the aggregation rule for a Revenue column to Sum.
Create Calculated Measures
If a fact table does not include all the measures that you need, then you can create calculated measures. For example, you can create a calculated measure called Average Order Size using the formula Revenue/Number of Orders.
About Creating Calculated Measures
Calculated measures, as the name suggests, are calculated from other measures. For example, you can create a measure that calculates Average Order Size using the formula Revenue/Number of Orders.
-
Calculation includes aggregated measures:
Sum(Revenue)/Sum(Orders)
-
Calculation includes measures with no aggregation applied:
UnitPrice X Quantity
If the measures in your calculation aren’t pre-aggregated, such as
UnitPrice
andQuantity
, you may apply aggregation after the calculation. For example,
.Sum(UnitPrice X Quantity)
Check the measures in your calculations before choosing whether to apply aggregation Before Calculating or After Calculating your expression.
Calculations Include Measures Already Aggregated
Set Aggregation to Before calculating if the calculation contains pre-aggregated measures. For example: Sum(Revenue)/Sum(Orders)
.
Calculations Include Non Aggregated Measures
Optionally, you can apply aggregation after your calculation. Set Aggregation to After calculating and then select an aggregation rule from the list. For example, Sum, Average, Count and so on.
Don’t include expression columns in the calculation. If you include aggregated columns in the calculation, aggregation on the columns is ignored.
Create Derived Attributes
You can create custom or derived attributes for dimension tables that are based on an expression. For example, you can use an expression to concatenate multiple address columns into a single Full Address column.
Create Expressions in the Expression Editor
You can use the Expression Editor to create constraints, aggregations, and other transformations on columns.
Topics:
About the Expression Editor
When modeling data, you can use the Expression Editor to create constraints, aggregations, and other transformations on columns. For example, you can use the Expression Editor to change the data type of a column from date to character. You can also use the Expression Editor to create expressions for data filters.
The Expression Editor contains the following sections:
-
The Expression box on the left-hand side enables you to edit the current expression.
-
The toolbar at the bottom contains commonly used expression operators, such as a plus sign, equals sign, or comma to separate items.
-
The Expression Elements section on the right-hand side provides building blocks that you can use in your expression. Examples of elements are tables, columns, functions, and types.
The Expression Elements section only includes items that are relevant for your task. For example, if you open the Expression Editor to define a calculated measure, the Expression Elements section only includes the current fact table, any dimension tables joined to that table, plus any fact tables indirectly joined through a dimension table. Similarly, when you define a derived attribute, you see the current dimension table, any fact tables joined to that table, and any dimension table joined to those fact tables.
Another example is that time hierarchies are only included if the Time fact table is joined to the current table.