262 Practical PowerPivot & DAX Formulas for Excel 2010
T
his is the second chapter dealing with DAX Date & Time functions. The
previous chapter discusses some of the basic Date and Time functions. In this
chapter, the emphasis is on the time intelligence Date and Time functions.
The time intelligence functions are primarily used to navigate dates. In particular, they
allow you to jump ahead or back in time and retrieve relevant data. This is useful if you
wish to compare your data across or between time periods. Practical applications would
include year-on-year changes. They allow you to compare the present date, in your filter
context, with past and future dates. In addition, these functions can help you define
ranges of dates or dates up to a particular date. A practical application here might
be year-to-date sales. The basic functions generally return dates and times. The time
intelligence functions generally return measures or values associated with dates and
times, or ranges of periods used by other functions to calculate these values.
C
Key concepts Jumping backward and forward in time, navigating time,
establishing date ranges, returning dates up to the current date, year-on-year
changes, year-to-date totals
C
Keywords CLOSINGBALANCEMONTH(), CLOSINGBALANCEQUARTER(),
CLOSINGBALANCEYEAR(), DATEADD(), DATESBETWEEN(),
DATESINPERIOD(), DATESMTD(), DATESQTD(), DATESYTD(),
ENDOFMONTH(), ENDOFQUARTER(), ENDOFYEAR(), FIRSTDATE(),
FIRSTNONBLANK(), LASTDATE(), LASTNONBLANK(), NEXTDAY(),
NEXTMONTH(), NEXTQUARTER(), NEXTYEAR(), OPENINGBALANCEMONTH(),
OPENINGBALANCEQUARTER(), OPENINGBALANCEYEAR(),
PARALLELPERIOD(), PREVIOUSDAY(), PREVIOUSMONTH(),
PREVIOUSQUARTER(), PREVIOUSYEAR(), SAMEPERIODLASTYEAR(),
STARTOFMONTH(), STARTOFQUARTER(), STARTOFYEAR(), TOTALMTD(),
TOTALQTD(), TOTALYTD()
C
Preparation ere are 35 time intelligence functions in DAX, and 35 in this
chapter. Most of them require that you have regular or calculated columns in
your PowerPivot model to cover standard time periods—that is, in addition to a
standard date column. If you wish to try the examples, please add the following
calculated columns to the Orders table in the Northwind PowerPivot model.
Instructions on how to create this model from a SQL Server source Northwind
are in Chapter 1. Instructions on how to do so from an Access, Excel, or data
feed Northwind are in Chapter 2. You will need calculated columns for the year,
quarter, and month of orders. If you worked through some of the earlier chapters,
you may already have a column for the year. Here are the DAX formulas for Year,