The second edition of The Definitive Guide to DAX is now available worldwide! This blog post explains why we felt the need to rewrite the book and describes what happens behind the scenes when producing a book.

When we (Marco Russo and Alberto Ferrari) decided it was time to update the first edition of “The Definitive Guide to DAX”, we thought it would be an easy job: after all, not many things have changed in the DAX language and the theoretical core of the book was still very good. We believed the focus would mainly be on updating the screenshots from Excel to Power BI, adding a few touch-ups here and there, and we would be done. How wrong we were!

As soon as we started updating the first chapter, we quickly discovered that we wanted to rewrite pretty much everything. We felt so not only in the first chapter, but at every page of the book. Therefore, this is not really a 2nd edition; it is a brand-new book.

The reason is not that the language or the tools have changed so drastically. The reason is that over these last few years we – as authors and teachers – have evolved a lot, hopefully for the better. We have taught DAX to thousands of users and developers all around the world, we have worked hard with our students, always striving for the best way to explain complex topics. Eventually, we did find different ways of describing the language we love.

We increased the number of examples, showing practical uses of the functionalities after teaching the theoretical foundation of DAX. We tried to use a simpler style, without compromising on precision. We fought with the editor to increase the page count, as this was needed to cover all the topics we wanted to share. Nevertheless, we did not change the leitmotif of the book: we assume no previous knowledge of DAX on the reader’s part, even though this is not a book for the casual DAX developer. This is a book for people who really want to learn the language and gain a deep understanding of the power and complexity of DAX.

Yes, if you want to leverage the real power of DAX, you need to be prepared for a long journey with us… Reading the book from cover to cover, and then reading it again, searching for the many details that – at first sight – are not obvious.

What’s new

Now, if you have already read the first edition and you master DAX, why should you get this second edition? Here is a list of what we added/changed in the new book:

  • Examples in Power BI: the first edition was published in 2015. Power BI had just been released and Power Pivot for Excel was the tool using DAX with the largest number of users around the world – today Power BI holds 80 to 90% of this market. In the first edition, most of the examples were in Excel, in the second edition all the examples are in Power BI.
  • Variables: the first edition presented variables in a separate chapter, but variables were never used in other chapters. Variables were only supported in Power BI, so most of the readers would not have been able to use them. The second edition uses variables everywhere, because using variables is a coding style that makes DAX easier to read, easier to write, and easier to debug. If you are not using variables, you should be.
  • Technical language: the more advanced parts of the first edition were intended to be used by advanced users with a former background in database modeling and programming languages – considering that certain techniques would only have been useful for large and/or complex models designed in Analysis Services. Power BI changed the game, extending the ability to create complex models with a large amount of data to data analysts that can now manage the complexity of complex formulas without former training to understand a technical language familiar to database administrators and BI developers. The second edition simplifies the language used without any compromise in accuracy. If this goes unnoticed by experienced developers and enables more data analysts to implement their requirements, we can proudly say we have achieved our goal.
  • Performance analysis: the chapters describing how to analyze performance and solve bottlenecks were based on detailed technical descriptions of information accessible only through data management views, SQL Server Management Studio, and SQL Profiler. However, DAX Studio – free and open source – is now the obvious tool to use to optimize DAX expressions; all the descriptions of actions required to evaluate the performance are now tasks based on DAX Studio. It is a faster, easier, and more productive process.
  • Best practices: in the last few years, we have analyzed thousands of cases of DAX code generating incorrect results or displaying poor performance. The second edition includes the description of several best practices to avoid these problems.
  • Filter context description: what is a filter context? Because this is a concept unique to DAX, it is not easy to describe it using examples and similarities. A picture is worth a thousand words… So the second edition leverages a more “visual” explanation that should help you “get” the filter context better than ever before.
  • KEEPFILTERS: how do you apply a filter to a column without removing existing filters? By using KEEPFILTERS. The first edition was not clear about this and suggested an alternative way. It suggested using an explicit FILTER/VALUES over a column instead of the implicit FILTER/ALL generated by default by a filter predicate in CALCULATE. This is now better explained and it is reflected in all the examples where KEEPFILTERS is the best option.
  • Calculation groups: last but not least, the second edition offers an entire chapter about calculation groups. This actually delayed any planned release date – more on this in the “behind the scenes” section. This is a fundamental feature that will change the way you write DAX code again in future years, so the only way for us to release a book that would last a few years was by including this chapter. The chapter about calculation groups in this second edition plays a role similar to the chapter about variables in the first edition. We do not use calculation groups throughout the book – otherwise you would not have any working example in Power BI today – but we wanted to warn you about what to expect so you can make your long term plans accordingly. For this reason, we went the extra mile in explaining how calculation groups work and in providing best practices about how to use them once they are available.

Behind the scenes

We would also like to share a few details of what happened behind the scenes.

First of all, how much time does it take to write a book? More than you would think, because the time spent on Word is just a fraction of it. I am writing the first draft of this blog post while I wait for a football match to start on a sunny winter day in Brisbane, on July 27, 2019 (see the picture: 25°C/75°F on a winter day here is the norm). I just saw the pictures of our first readers, excitedly receiving the book they preordered months ago. It will take another few weeks before the book is available worldwide and you read the final version of this post. We sent the book proposal for the second edition in July 2017. Two years ago! We signed the contract with the publisher in October 2018. We had been collecting ideas and notes since early 2017 and we started to write the first draft of the second edition in November 2017. We started the technical review of the first chapters in July 2018. We completed the draft of the last chapter at the end of 2018, but we had to wait until April 2019 to complete the chapter about Calculation Groups – only at that point did we have enough information about the feature that would be released by the end of 2019 – side note: we have a page dedicated to articles about Calculation Groups that we will update to stay aligned with future evolutions of this feature. We signed off on the book in May 2019 and two months later it was printed.

We carefully studied the reviews of the first edition of the book. Although the first edition did gather very good ratings and reviews, we always look for possible improvements. Once we started seeing one or two comments about the language used and the grammar, we tried to understand how it was possible that text reviewed by two or three professional editors that are native English speakers could generate that kind of feedback. The answer is probably not simple – perhaps a mix of complex technical concepts in an English that was formally correct but not clear enough in certain sentences. For these reasons, we added an additional layer of editorial review in the early stage of draft production. We also amended a few of the rules of the publisher house style guide that were not helpful in clarifying certain details of the concepts. While we kept North American English as a reference for consistency, we also kept in mind that the book targets an international audience. In this case not being native English speaking authors is an advantage, but it is not easy to always be aware that certain examples can be obvious in some cultures and totally misleading or nonsense in others.

In the last 12 months, we spent time trying to clarify that the book release date available on Amazon was wrong. How could this happen? We had a conflict with automation and standardization. There are millions of books in the world, and thousands more are released every week. Therefore, publishers send files to distributors, containing book titles and expected release dates, so that the distribution side can plan logistics and advertising, thus optimizing many processes. A book contract must have a release date, even though in our case the condition was “the book will be ready after we have enough information about calculation groups”. Well, this could be simplified as “the book will be ready when it is complete”. But this is not compatible with the process. So the file was sent out with the wrong release date and used by distributors to announce an upcoming new title and gather preorders. After a few months Amazon removed the release date entirely because it was delayed too much and there was no way in this process to fix the error. We tried hard, really. So, next time you see a planned release date, only trust it if you know that the product is ready and that they are waiting to release it because of some planned launch event. The system works the way it works.

When we receive a report for a mistake in the book, we always wonder how it is possible that so many people during the production cycle (including the technical review) could miss a discrepancy between the text and a picture, or miss the fact that the file saved for a demo is different from the bitmap. There is always a good explanation – you might justify them as exceptions – yet we wanted to improve this. In reality the first edition had very few errors, but it would have been a big risk to get the same technical editors; we needed someone who would have used the book to study DAX at a higher level. We also modified the way we save the files. We created one file for each figure in the book – this may be redundant but it removes any ambiguity in interpreting the result. We also went into full paranoid mode in the technical review, finding someone who was able to follow our rules and carefully test every example. I know that there are still a few mistakes in more than 700 pages, but I feel good because we did everything possible to reduce them.

The world is made up of physical objects, and printed books still play a big role in the industry. Yes, we have eBooks, and it is much easier to get your copy around this way. But for certain books, many people want the printed version – maybe both. This creates a logistical issue related to printing and distribution. Once the book is signed off (May 2019 in this case) it is queued up for printing. When a production batch is ready, it is shipped to distribution. But printed books must be moved in trucks and containers around the world. If the book is printed in the United States, it takes a few weeks before it is available in other continents. For this reason, we waited a few weeks after the initial printing before announcing the book, just to be sure it would actually be available worldwide.

The last question is: what’s next? We have already started working on the next project: Having released DAX Patterns at the end of 2014, we are working on a new version with more optimized code, more patterns, and more practical examples. In the meantime, refresh your DAX knowledge with The Definitive Guide to DAX!

CALCULATE modifier

Changes the CALCULATE and CALCULATETABLE function filtering semantics.

KEEPFILTERS ( <Expression> )

Context transition

Evaluates an expression in a context modified by filters.

CALCULATE ( <Expression> [, <Filter> [, <Filter> [, … ] ] ] )