Sie sind auf Seite 1von 1

DAX: Calculated Columns vs.

Measures
DAX is the language used to dene calculation expressions in PowerPivot and Microsoft SQL Server Analysis Services (00:23). The same DAX syntax can be used to dene two dierent types of formulas. Calculated columns are calculated row-by-row when the content of a table is refreshed, whereas measures are computed at query time, by aggregating rows. In the rst demo shown in this video, we create a simple calculated column (2:07), based on the Sales table of the AdventureWorks DW sample database (download here). We calculate the product of quantity by price, obtaining the LineTotal column. In order to display an aggregation of LineTotal in a PivotTable, we need to dene a measure (04:09). Well do that in two ways: rst, by summing the previously dened LineTotal column, and later by using a SUMX function, which performs a row-by-row multiplication at query time, without relying on a calculated column. Knowing both techniques is important: even if a pure measure is usually better, aggregating a calculated column might be preferable whenever the row-by-row calculation is particularly complex. An important dierence between calculated columns and measures is that you can use the result of a calculated column in a slicer. We create a calculated column (07:07) that classify unit price of products in three categories, implementing all the logic in a DAX formula, whose result is persisted row-byrow, every time the table is refreshed. We should always use calculated columns when they might be used as a lter criteria in the data model. However, we should always prefer measures over calculated columns (09:46), whenever possible, because of the lower consumption of RAM, thanks to the query-time evaluation of the DAX formula, whose results are not persisted. As you now understand, the rst step in using DAX is learning the dierence between calculated columns and measures, in order to make the right choice at design time. Proceed now to learn the fundamentals of this language from the other videos in our series on DAX.

Das könnte Ihnen auch gefallen