Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Analyzing Data with Power BI and Power Pivot for Excel (Alberto Ferrari, Marco Russo) (z-lib.org).pdf
Скачиваний:
11
Добавлен:
14.08.2022
Размер:
18.87 Mб
Скачать

many relationship.

Measures and additivity

When you define a measure, an important concept is whether the measure is additive or not against a specific dimension.

Additive measures

A measure is said to be additive when it aggregates by using a simple sum. For example, the amount sold is additive against products, meaning that the total sold results from the sum of sales of individual products. As another example, Sales is additive against all dimensions because the total sold over a year results from the sum of the sales of individual days.

Non-additive measures

There is another category of calculations that is known as non-additive. Distinct count, for example, is a non-additive calculation. If you perform a distinct count of the product sold, then the distinct count over one year is not the sum of the distinct counts over individual months. The same applies to customers, countries, and any other dimension (apart from the product). Whenever you need to compute a nonadditive measure, you must perform a full scan of the table for each level of the hierarchy that you are browsing because you cannot aggregate values from their children.

Semi-additive measures

The third category of calculations is semi-additive. Semi-additive measures are the most complex measures because they are additive against some dimensions and non-additive against others. Typically, the dimension that acts as an exception is time. For example, a Year-to-Date calculation is non-additive because the value you show for one month (for example, March) is not the sum of the individual days. Instead it is the value of the last day of the month. Figure A-15 shows an example of these three kinds of measures.

Figure A-15 The report shows the three types of additivity: additive, semiadditive, and nonadditive.

DAX offers a set of functions to handle semi-additivity over time. Functions like DATESYTD, TOTALYTD, LASTDATE, and CLOSINGBALANCEQUARTER help you author semi-additive measures when time is the non-additive dimension. Handling semi-additivity over different dimensions requires more complex FILTER functions because there is no predefined function to handle nonadditivity on dimensions that are not related to time.