Microsoft Certified: Power BI Data Analyst AssociateModel the dataMedium

A data modeler is optimizing a Power BI model for a large enterprise. The model contains a 'Sales' fact table and several dimension tables, including 'Product', 'Customer', and 'Date'. The 'Sales' table has millions of rows and includes both 'OrderQuantity' and 'UnitPrice' columns. The modeler needs to calculate 'LineTotal' for each row in the 'Sales' table, which is the product of 'OrderQuantity' and 'UnitPrice'. This calculation will be used frequently in various reports and needs to be highly performant. Which of the following DAX approaches is the most efficient and recommended for calculating 'LineTotal' directly within the 'Sales' table?

  1. ACreate a measure using `CALCULATE(SUM(Sales[OrderQuantity] * Sales[UnitPrice]))`.
  2. BCreate a calculated column using `Sales[OrderQuantity] * Sales[UnitPrice]`.
  3. CCreate a measure using `SUMX(Sales, Sales[OrderQuantity] * Sales[UnitPrice])`.
  4. DUse a transformation in Power Query to add a custom column for 'LineTotal'.
Show answer & explanation

Correct answer: B. Create a calculated column using `Sales[OrderQuantity] * Sales[UnitPrice]`.

For row-level calculations that are static and will be used repeatedly, a calculated column is generally the most efficient DAX approach. It pre-calculates and stores the values, making retrieval faster during reporting. Power Query is also an option but if the calculation needs to be dynamic or depends on other DAX measures, a calculated column is preferred over a measure for static row-level results.

Why the other options are wrong

  • A. This is an incorrect DAX syntax and an inefficient approach for a simple row-level calculation; CALCULATE is for modifying filter context.
  • C. This creates a measure, which calculates on the fly and aggregates the results, making it less efficient for simple row-level storage.
  • D. While Power Query can add a custom column, the question specifically asks for a DAX approach. A calculated column in DAX directly addresses the requirement for a row-level calculation within the data model.

Calculated Column for Row-Level Operations

A calculated column in DAX adds a new column to a table with values computed at the row level, suitable for static, row-by-row calculations.

  • Values are computed during data refresh and stored in the model.
  • Ideal for static, row-level calculations that are frequently used.
  • Increases model size but improves query performance for pre-calculated values.

Memory trick: Columns Compute Constantly, Measures Make Dynamic.

More Model the data questions