Microsoft Certified Power Bi Data Analyst Associate · Free Practice Question Medium

Question 17

A Power BI Data Analyst is building a sales report that requires time-based analysis, such as year-to-date (YTD) and month-over-month comparisons. The dataset includes a Sales table with a SaleDate column but no dedicated date table. The analyst needs to create and configure a date table to enable accurate time intelligence calculations in DAX.
Which approach should the analyst take to configure the date table correctly?

  • A

    Add calculated columns for Year and Month to the Sales table and use these for time-based calculations.

  • B

    Use the CALENDAR function in DAX to create a date table, set the Date column as the key, and enable time intelligence in Power BI.

  • C

    Create a new table in Power Query with a list of dates, add columns for Year and Month, and mark it as a date table in Power BI.

  • D

    Import a date table from an external Excel file, link it to the SaleDate column, and disable time intelligence in Power BI.

  • E

    Use the DATEADD function in DAX to generate a date table and relate it to the SaleDate column.

Reveal correct answer

Correct answer: C

Explanation

Problem Breakdown

The analyst is building a sales report requiring time-based analysis (e.g., year-to-date and month-over-month comparisons) using a Sales table with a SaleDate column but no dedicated date table. The requirement is to:

  • Create and configure a date table to enable accurate time intelligence calculations in DAX.

Domain: Prepare the Data

Why This Configuration?

  • Create a New Table in Power Query:

    • Power Query is an efficient tool for creating a date table by generating a list of dates, which can be customized with additional columns (e.g., Year, Month) to support time-based analysis.

    • This approach allows the analyst to define a date range (e.g., covering all SaleDate values) and add attributes like Year, Month, Quarter, or Week for flexible analysis.

  • Add Columns for Year and Month:

    • Adding columns for Year, Month, and other time attributes (e.g., Quarter, Day) in Power Query enables DAX time intelligence functions (e.g., TOTALYTD, PREVIOUSMONTH) to work seamlessly for calculations like YTD or month-over-month comparisons.

    • These columns provide the granularity needed for report visuals and filters.

  • Mark as a Date Table in Power BI:

    • Marking the table as a Date Table in Power BI (via the Modeling tab) ensures DAX time intelligence functions recognize it as the primary date table. This requires specifying the Date column as the key, enabling accurate calculations and built-in hierarchies (e.g., Year > Quarter > Month).

How It Works

  1. In Power BI Desktop, open Power Query Editor (Home > Transform Data).

  2. Create a new table:

    • Go to Home > New Source > Blank Query.

    • Use a formula to generate a date range, e.g., = List.Dates(#date(2020, 1, 1), 1826, #duration(1, 0, 0, 0)) to create dates from Jan 1, 2020, to Dec 31, 2024 (covering likely SaleDate range).

    • Convert the list to a table (Transform > To Table) and name the column Date.

  3. Add columns for time attributes:

    • Year: = Date.Year([Date]).

    • Month: = Date.MonthName([Date]) or = Date.Month([Date]).

    • Optionally, add Quarter, Week, etc., using similar Date functions.

  4. Set the Date column data type to Date and ensure it has no duplicates.

  5. Load the table to Power BI (Close & Apply).

  6. In the Modeling tab, relate the date table to Sales[SaleDate] (one-to-many, single-directional).

  7. Mark the table as a Date Table:

    • Select the table, go to Modeling > Date Table > Mark as Date Table, and set the Date column as the key.

  8. Use the date table in DAX calculations (e.g., TotalYTD = TOTALYTD(SUM(Sales[Amount]), 'Date'[Date])) and visuals.

Why Not the Other Options?

  • Use CALENDAR Function in DAX:

    • While CALENDAR creates a date table, it requires additional DAX to add Year, Month, etc., which is less flexible than Power Query for transformations. It also loads data into the model directly, potentially increasing memory usage.

  • Import from Excel and Disable Time Intelligence:

    • Importing an external Excel file adds complexity and dependency on external sources. Disabling time intelligence prevents DAX functions like TOTALYTD from working, failing the requirement.

  • Add Calculated Columns to Sales Table:

    • Adding Year and Month to the Sales table bloats the fact table, increasing memory usage and lacking the structure of a dedicated date table for time intelligence.

  • Use DATEADD to Generate Date Table:

    • DATEADD is a DAX function for shifting dates in calculations, not for creating a date table. It’s unsuitable for this purpose.

Practical Considerations

  • Date Range: Ensure the date table covers all SaleDate values (e.g., min and max dates in the Sales table) to avoid missing data in calculations.

  • Relationship: Verify the relationship between Date[Date] and Sales[SaleDate] is single-directional to optimize filter propagation.

  • Time Attributes: Include additional columns (e.g., Quarter, Fiscal Year) based on reporting needs.

  • Testing: Test DAX time intelligence functions (e.g., TOTALYTD, PREVIOUSMONTH) to ensure accurate results.

References:

A.

Adding calculated columns to the Sales table creates redundancy and doesn’t provide a separate date table for proper time intelligence, leading to inefficient modeling.

B.

The CALENDAR function in DAX creates a date table, but it doesn’t automatically include additional columns like Month or Quarter, and there’s no option to “enable time intelligence” in Power BI. The Date column must also be properly related to the Sales table.

C.

Creating a date table in Power Query with a continuous range of dates and adding columns like Year and Month allows for flexible time intelligence. Marking it as a date table in Power BI (via the "Mark as Date Table" option) ensures DAX time intelligence functions like TOTALYTD work correctly.

D.

Importing an external Excel file can work, but disabling time intelligence prevents the use of DAX functions like TOTALYTD, which contradicts the requirement for time-based analysis.

E.

DATEADD is a DAX function for shifting dates in calculations, not for creating a date table, making it unsuitable for this purpose.

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need