Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
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б
Скачать

a simple variation on the formulas you have seen so far, as shown in the following DAX code:

Click here to view code image

Sales2008AtBudgetGranularity := CALCULATE (

[Sales 2008], ALL ( Store ),

VALUES ( Store[CountryRegion] ), ALL ( Product ),

VALUES ( Product[Brand] )

)

AllocationFactor := DIVIDE ( [Sales 2008], [Sales200

Allocated Budget := SUM ( Budget[Budget] ) * [Alloca

The core of the previous formulas is Sales2008AtBudgetGranularity, which computes the sales amount after removing filters from Store and Product, apart from the columns that define the granularity at the Budget level. The remaining two measures are a simple division and a multiplication. Use the numbers shown in Figure 9-14 to produce the desired result.

The technique of reallocating at the higher granularity is very interesting, and it gives the user the feeling that numbers are present at a higher granularity than they really are. However, if you plan to use this technique, you should clearly explain how the numbers are computed to the stakeholders. At the very end, the numbers are derived from a calculation, and they are not what is entered when the budget is created.

Conclusions

Granularity is one topic you need to understand to build any data model, and has been discussed in many chapters throughout this book. This chapter went a step further to analyze some options that are available when granularity cannot be fixed because data is already stored at the right level.

The most important topics covered in this chapter are as follows:

Granularity is defined by the level at which the dimensions are linked to the fact table.

Different fact tables can present different levels of granularity because of

the nature of their data. Usually, granularity issues are errors in the model. However, there are scenarios where fact tables are stored at the correct granularity, which is different from table to table.

When multiple fact tables have different granularity, you must build a model that lets you slice all the tables using one dimension. You can do so either by creating a special model at the correct granularity or by moving the filter through DAX code or bidirectional relationships.

You must be aware of granularity differences among your facts and handle them properly. You have multiple options: ignoring the problem, hiding the data when granularity becomes too high, or reallocating the values using some allocation factor.