Home > Store

Definitive Guide to DAX, The: Business intelligence for Microsoft Power BI, SQL Server Analysis Services, and Excel, 2nd Edition

eBook (Watermarked)

  • Your Price: $29.91
  • List Price: $37.39
  • Includes EPUB and PDF
  • About eBook Formats
  • This eBook includes the following formats, accessible from your Account page after purchase:

    ePub EPUB The open industry format known for its reflowable content and usability on supported mobile devices.

    Adobe Reader PDF The popular standard, used most often with the free Acrobat® Reader® software.

    This eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.

Also available in other formats.

Companion Files

Click here to download the companion files (1.4 GB .zip). If prompted, click Save. Then locate the .zip file on your computer, right-click the file, click Extract All, and follow the instructions.

Register your product to gain access to bonus material or receive a coupon.


  • Copyright 2020
  • Dimensions: 7-3/8" x 9-1/8"
  • Pages: 768
  • Edition: 2nd
  • eBook (Watermarked)
  • ISBN-10: 0-13-486589-8
  • ISBN-13: 978-0-13-486589-8

Now expanded and updated with modern best practices, this is the most complete guide to Microsoft’s DAX language for business intelligence, data modeling, and analytics. Expert Microsoft BI consultants Marco Russo and Alberto Ferrari help you master everything from table functions through advanced code and model optimization. You’ll learn exactly what happens under the hood when you run a DAX expression, and use this knowledge to write fast, robust code. This edition focuses on examples you can build and run with the free Power BI Desktop, and helps you make the most of the powerful syntax of variables (VAR) in Power BI, Excel, or Analysis Services. Want to leverage all of DAX’s remarkable capabilities? This no-compromise “deep dive” is exactly what you need.

Perform powerful data analysis with DAX for Power BI, SQL Server, and Excel

·         Master core DAX concepts, including calculated columns, measures, and calculation groups

·         Work efficiently with basic and advanced table functions

·         Understand evaluation contexts and the CALCULATE and CALCULATETABLE functions

·         Perform time-based calculations

·         Use calculation groups and calculation items

·         Use syntax of variables (VAR) to write more readable, maintainable code

·         Express diverse and unusual relationships with DAX, including many-to-many relationships and bidirectional filters

·         Master advanced optimization techniques, and improve performance in aggregations

·         Optimize data models to achieve better compression

·         Measure DAX query performance with DAX Studio and learn how to optimize your DAX 



Follow the instructions to download this book's companion files. NOTE: File size is approximately 1.4 GB.

  1. Click the Download button below to start the download.
  2. If prompted, click Save.
  3. Locate the .zip file on your computer. Right-click the file, click Extract All, and then follow the instructions.

Sample Content

Sample Pages

Download the sample pages (includes Chapter 4, 17, and the index)

Table of Contents


Introduction to the second edition

Introduction to the first edition

Chapter 1 What is DAX?

Understanding the data model

    Understanding the direction of a relationship

DAX for Excel users

    Cells versus tables

    Excel and DAX: Two functional languages

    Iterators in DAX

    DAX requires theory

DAX for SQL developers

    Relationship handling

    DAX is a functional language

    DAX as a programming and querying language

    Subqueries and conditions in DAX and SQL

DAX for MDX developers

    Multidimensional versus Tabular

    DAX as a programming and querying language


    Leaf-level calculations

DAX for Power BI users

Chapter 2 Introducing DAX

Understanding DAX calculations

    DAX data types

    DAX operators

    Table constructors

    Conditional statements

Understanding calculated columns and measures

    Calculated columns


Introducing variables

Handling errors in DAX expressions

    Conversion errors

    Arithmetic operations errors

    Intercepting errors

    Generating errors

Formatting DAX code

Introducing aggregators and iterators

Using common DAX functions

    Aggregation functions

    Logical functions

    Information functions

    Mathematical functions

    Trigonometric functions

    Text functions

    Conversion functions

    Date and time functions

    Relational functions


Chapter 3 Using basic table functions

Introducing table functions

Introducing EVALUATE syntax

Understanding FILTER

Introducing ALL and ALLEXCEPT

Understanding VALUES, DISTINCT, and the blank row

Using tables as scalar values



Chapter 4 Understanding evaluation contexts

Introducing evaluation contexts

    Understanding filter contexts

    Understanding the row context

Testing your understanding of evaluation contexts

    Using SUM in a calculated column

    Using columns in a measure

Using the row context with iterators

    Nested row contexts on different tables

    Nested row contexts on the same table

    Using the EARLIER function

Understanding FILTER, ALL, and context interactions

Working with several tables

    Row contexts and relationships

    Filter context and relationships

Using DISTINCT and SUMMARIZE in filter contexts


Chapter 5 Understanding CALCULATE and CALCULATETABLE


    Creating filter contexts

    Introducing CALCULATE

    Using CALCULATE to compute percentages

    Introducing KEEPFILTERS

    Filtering a single column

    Filtering with complex conditions

    Evaluation order in CALCULATE

Understanding context transition

    Row context and filter context recap

    Introducing context transition

    Context transition in calculated columns

    Context transition with measures

Understanding circular dependencies

CALCULATE modifiers

    Understanding USERELATIONSHIP

    Understanding CROSSFILTER

    Understanding KEEPFILTERS

    Understanding ALL in CALCULATE

    Introducing ALL and ALLSELECTED with no parameters


Chapter 6 Variables

Introducing VAR syntax

Understanding that variables are constant

Understanding the scope of variables

Using table variables

Understanding lazy evaluation

Common patterns using variables


Chapter 7 Working with iterators and with CALCULATE

Using iterators

    Understanding iterator cardinality

    Leveraging context transition in iterators


    Iterators returning tables

Solving common scenarios with iterators

    Computing averages and moving averages

    Using RANKX

    Changing calculation granularity


Chapter 8 Time intelligence calculations

Introducing time intelligence

    Automatic Date/Time in Power BI

    Automatic date columns in Power Pivot for Excel

    Date table template in Power Pivot for Excel

Building a date table


    Working with multiple dates

    Handling multiple relationships to the Date table

    Handling multiple date tables

Understanding basic time intelligence calculations

    Using Mark as Date Table

Introducing basic time intelligence functions

    Using year-to-date, quarter-to-date, and month-to-date

    Computing time periods from prior periods

    Mixing time intelligence functions

    Computing a difference over previous periods

    Computing a moving annual total

    Using the right call order for nested time intelligence functions

Understanding semi-additive calculations


    Working with opening and closing balances

Understanding advanced time intelligence calculations

    Understanding periods to date

    Understanding DATEADD


    Using drillthrough with time intelligence

Working with custom calendars

    Working with weeks

    Custom year-to-date, quarter-to-date, and month-to-date


Chapter 9 Calculation groups

Introducing calculation groups

Creating calculation groups

Understanding calculation groups

    Understanding calculation item application

    Understanding calculation group precedence

    Including and excluding measures from calculation items

Understanding sideways recursion

Using the best practices


Chapter 10 Working with the filter context



Understanding differences between VALUES and FILTERS

Understanding the difference between ALLEXCEPT and ALL/VALUES

Using ALL to avoid context transition


Introducing data lineage and TREATAS

Understanding arbitrarily shaped filters


Chapter 11 Handling hierarchies

Computing percentages over hierarchies

Handling parent/child hierarchies


Chapter 12 Working with tables


Manipulating tables




    Using UNION


    Using EXCEPT

Using tables as filters

    Implementing OR conditions

    Narrowing sales computation to the first year’s customers

    Computing new customers

    Reusing table expressions with DETAILROWS

Creating calculated tables


    Creating static tables with ROW

    Creating static tables with DATATABLE



Chapter 13 Authoring queries

Introducing DAX Studio

Understanding EVALUATE

    Introducing the EVALUATE syntax

    Using VAR in DEFINE


Implementing common DAX query patterns

    Using ROW to test measures



    Using TOPN




    Using TOPNSKIP

    Using GROUPBY



    Using SAMPLE

Understanding the auto-exists behavior in DAX queries


Chapter 14 Advanced DAX concepts

Introducing expanded tables

    Understanding RELATED

    Using RELATED in calculated columns

Understanding the difference between table filters and column filters

    Using table filters in measures

    Understanding active relationships

    Difference between table expansion and filtering

    Context transition in expanded tables

Understanding ALLSELECTED and shadow filter contexts

    Introducing shadow filter contexts

    ALLSELECTED returns the iterated rows

    ALLSELECTED without parameters

The ALL* family of functions






Understanding data lineage


Chapter 15 Advanced relationships

Implementing calculated physical relationships

    Computing multiple-column relationships

    Implementing relationships based on ranges

    Understanding circular dependency in calculated physical relationships

Implementing virtual relationships

    Transferring filters in DAX

    Transferring a filter using TREATAS

    Transferring a filter using INTERSECT

    Transferring a filter using FILTER

    Implementing dynamic segmentation using virtual relationships

Understanding physical relationships in DAX

Using bidirectional cross-filters

Understanding one-to-many relationships

Understanding one-to-one relationships

Understanding many-to-many relationships

    Implementing many-to-many using a bridge table

    Implementing many-to-many using a common dimension

    Implementing many-to-many using MMR weak relationships

Choosing the right type of relationships

Managing granularities

Managing ambiguity in relationships

    Understanding ambiguity in active relationships

    Solving ambiguity in non-active relationships


Chapter 16 Advanced calculations in DAX

Computing the working days between two dates

Showing budget and sales together

Computing same-store sales

Numbering sequences of events

Computing previous year sales up to last date of sales


Chapter 17 The DAX engines

Understanding the architecture of the DAX engines

    Introducing the formula engine

    Introducing the storage engine

    Introducing the VertiPaq (in-memory) storage engine

    Introducing the DirectQuery storage engine

    Understanding data refresh

Understanding the VertiPaq storage engine

    Introducing columnar databases

    Understanding VertiPaq compression

    Understanding segmentation and partitioning

    Using Dynamic Management Views

Understanding the use of relationships in VertiPaq

Introducing materialization

Introducing aggregations

Choosing hardware for VertiPaq

    Hardware choice as an option

    Set hardware priorities

    CPU model

    Memory speed

    Number of cores

    Memory size

    Disk I/O and paging

    Best practices in hardware selection


Chapter 18 Optimizing VertiPaq

Gathering information about the data model


Columns cardinality

Handling date and time

Calculated columns

    Optimizing complex filters with Boolean calculated columns

    Processing of calculated columns

Choosing the right columns to store

Optimizing column storage

    Using column split optimization

    Optimizing high-cardinality columns

    Disabling attribute hierarchies

    Optimizing drill-through attributes

Managing VertiPaq Aggregations


Chapter 19 Analyzing DAX query plans

Capturing DAX queries

Introducing DAX query plans

    Collecting query plans

    Introducing logical query plans

    Introducing physical query plans

    Introducing storage engine queries

Capturing profiling information

    Using DAX Studio

    Using the SQL Server Profiler

Reading VertiPaq storage engine queries

    Introducing xmSQL syntax

    Understanding scan time

    Understanding DISTINCTCOUNT internals

    Understanding parallelism and datacache

    Understanding the VertiPaq cache

    Understanding CallbackDataID

Reading DirectQuery storage engine queries

    Analyzing composite models

    Using aggregations in the data model

Reading query plans


Chapter 20 Optimizing DAX

Defining optimization strategies

    Identifying a single DAX expression to optimize

    Creating a reproduction query

    Analyzing server timings and query plan information

    Identifying bottlenecks in the storage engine or formula engine

    Implementing changes and rerunning the test query

Optimizing bottlenecks in DAX expressions

    Optimizing filter conditions

    Optimizing context transitions

    Optimizing IF conditions

    Reducing the impact of CallbackDataID

    Optimizing nested iterators

    Avoiding table filters for DISTINCTCOUNT

    Avoiding multiple evaluations by using variables


9781509306978   TOC   5/23/2019


Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information

Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


This site is not directed to children under the age of 13.


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure

Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact

Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice

We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020