DAX Year-Month sorting

In this example, a DAX calculated column is created to support sorting of the Calendar Yr-Mo column.

  1. Access the Date table in Data view and click on New Column from the Modeling tab.
  2. Enter the following DAX expression to create sorting column at the grain of calendar months across years:
DAX Sorting Calculated Column
  • The YEAR() function is applied against the Date column and multiplied by 100 to add two digits:
    • MONTH() returns a value of 1 to 12 and this is added to the six digit number
Although this approach is simple to implement and inexpensive in resource usage, the values of the new column are not sequential ...

Get Microsoft Power BI Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.