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

more complex scenario into smaller ones. Thus, each single formula is much simpler and easier to write and debug, and the final aggregation formulas become extremely easy to write and fast to execute.

Conclusions

This chapter deviated from the standard models to perform a deeper analysis of scenarios in which duration is the primary concept. As you have seen, duration forces you to think in a slightly different way, redefining the very concept of a fact. You might store a fact along with its duration, but in doing so, you will need to reconsider the concept of time because a single fact might extend its effects into different periods. The following is a brief overview of what you learned in this chapter:

Date and time must be separate columns.

Aggregating simple intervals is easy. You should only try to reduce the cardinality of the facts to the best one that satisfies your analytical needs, and at the same time, reduce the cardinality of the Time column.

When you store duration (or intervals) that cross the time dimension, you must define the model in the right way. There are many options, and you are responsible for finding the best one. The good news is that you can move from one solution to another by simply changing the data model. Then, you can use the one that works best for your specific scenario.

Sometimes, changing the way you think about time might help. If your day does not end at midnight, you can model it the way you want—for example, making it start at 2:00 a.m. You are not a slave of the model. Instead, it is the model that must change according to your needs.

Analysis of active events is a very common scenario that is frequently used in many businesses. You learned multiple ways of solving this scenario. The more tailored the model, the easier the DAX code, but at the same time, the more complex the data-preparation steps.

When you have multiple tables where each one defines its own set of durations, trying to solve the problem with a single DAX measure makes the code very complex. On the other hand, pre-computing the values in a calculated column or a calculated table and obtaining the right degree of denormalization will lead to much simpler DAX code, which you can trust more.

The main takeaway is nearly always the same: If the DAX code becomes too complex, then it is a very good indicator that you might need to work on the

model. Although it is true that the model should not be built for a single report, it is also true that a good model is the key to an efficient solution.