Book Image

Extreme DAX

By : Michiel Rozema, Henk Vlootman
Book Image

Extreme DAX

By: Michiel Rozema, Henk Vlootman

Overview of this book

This book helps business analysts generate powerful and sophisticated analyses from their data using DAX and get the most out of Microsoft Business Intelligence tools. Extreme DAX will first teach you the principles of business intelligence, good model design, and how DAX fits into it all. Then, you’ll launch into detailed examples of DAX in real-world business scenarios such as inventory calculations, forecasting, intercompany business, and data security. At each step, senior DAX experts will walk you through the subtleties involved in working with Power BI models and common mistakes to look out for as you build advanced data aggregations. You’ll deepen your understanding of DAX functions, filters, and measures, and how and when they can be used to derive effective insights. You’ll also be provided with PBIX files for each chapter, so that you can follow along and explore in your own time.
Table of Contents (17 chapters)
Free Chapter
1
Part I: Introduction
6
Part II: Business cases
15
Other Books You May Enjoy
16
Index

Basic inventory calculations

Let us start by answering the most basic question: what is the actual inventory? Because of the way we have modeled our data, this one is easy to do:

Actual Inventory =
CALCULATE(
    SUM(fInventory[Quantity]),
    fInventory[Type] = 0
)

All we need to do is retrieve the rows with [Type] = 0, as it is in those where the actual inventory is stored.

There is one issue with this calculation, however: it assumes that we have selected the whole of the Calendar table, or at least made a selection that includes the date with the Type 0 rows. After all, when we select last year, the rows containing the current inventory will not be selected. It would be better to create a measure that returns a result for any selection on Calendar.

If we assume that we have some selection in Calendar, the first question to ask is: which exact date do we pick to return the status for? After all, the inventory status is strictly date-specific.

The common practice...