Comparing previous periods

For the first set of date patterns, we are going to look at some DAX expressions to create measures that will compare values over equivalent periods. The first of these will give the total sales quantity for the same period of the previous year.

The following expression will create a measure called Sales Quantity PY that will give the total sales quantity for the equivalent date in the previous year:

Sales Quantity PY =CALCULATE (    SUM ( Sales[Sales Quantity] ),    SAMEPERIODLASTYEAR ( 'Date Table'[Date] ))

Figure 11-8 shows this measure being used to create a graph showing a comparison of sales quantity with the same period for the previous year:

Figure 11-8: Comparison of sales quantity with the same period for the ...

Get Hands-On Business Intelligence with DAX 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.