Minimize
24

One of the interesting DAX Time Intelligence functions is the TOTALYTD, which can define a measure calculation over a year in a cumulative way.

The same output can be achieved in alternate ways using the CALCULATE function.  Nevertheless, as it is a very common computation in Excel reports, the PowerPivot team has created a dedicated function in order to help developing YTD calculations much faster.

A TOTALYTD behavior that is worth nothing however, is the fact that if a filter context defines multiple years (perhaps accidentally), this function will then use the last year available in order to perform the aggregation.

The screenshots below show a simple pivot table using Adventure Works data.  The DAX measure defined for YTD aggregate is:

TOTALYTD(SUM([SalesAmount]), DimTime[FullDateAlternateKey], ALL(DimTime))

When the slicer selection specifies only one year, the regular aggregate of [Sales Amount] over each month as well as the DAX [YTD] measure act on that sole year.

 However when two years are selected, the regular aggregate of [Sales Amount] acts over the correct filter context (defined over two years), whereas the YTD measure uses only the last year (2002). 

 

At first it can be confusing, but if you select different sets of multiple years in the slicers it becomes evident pretty quick that the YTD is only showing the latest year of the set. 

 

Although it can be argued that it is a good assumption given that the TOTALYTD function is not meant to work over multiple years, it is still worth documenting this behavior and keeping it in mind in case a complex report produces unexpected results due to a YTD formula that is picking for you what year should go into the calculation.

Comments

There are currently no comments, be the first to post one.

Post Comment

Only registered users may post comments.

MSBiCentral Bloggers Minimize

Latest Entries Minimize
Using VBA to enhance interactivity of PowerPivot reports by JavierGuillen
Presenting for PowerPivot Analytics Expo (hosted by SSWUG on July 15) by JavierGuillen
PowerPivot Analytics Expo
Quartile, Percentile and Median in PowerPivot by JavierGuillen
Using MDX in a PowerPivot model
Median calculation in PowerPivot / DAX by JavierGuillen
How to calculate median over a PowerPivot measure
Calculating moving averages in DAX by JavierGuillen
After SSRS 2008 R2 Upgrade: Some Reports Hang by wsnyder
You just upgraded to SSRS 2008 R2 and some reports are hanging up, while others seem to work fine. How do you debug for this, and what is the fix?
SSRS SystemOverflowexception: Value was either too large or too small for an Int32 by wsnyder
You install or upgrade to SSRS 2008R2 Gold, and get the following error "SSRS SystemOverflowexception: Value was either too large or too small for an Int32". Here is what is going on....
PASS Virtual Chapter Presentation Slides on PowerPivot / DAX by JavierGuillen
Presentation slides for PASS VC webinar on PowerPivot and DAX
Business Intelligence Prototyping with PowerPivot by JavierGuillen
PowerPivot can be a really powerful tool for prototyping Business Intelligence projects.
Speaking for PASS Business Intelligence Virtual Chapter by JavierGuillen
Page 1 of 3First   Previous   [1]  2  3  Next   Last   

Copyright 2004-2012 MSBICentral.com Terms Of Use Privacy Statement