| Solving the Events-In-Progress Problem in DAX V2.0 |
| Written by Chris Webb | |||
| Friday, 11 November 2011 21:47 | |||
|
Reposted from Chris Webb's blog with the author's permission. This is probably the 5th or 6th post I’ve written on this problem (most deal with MDX, but I did blog about solving it in DAX early last year) but what can I say – it’s an interesting problem! I came across it at work today while working with the 2012 CTP3 version of PowerPivot and found yet another solution to the problem that used some of the new DAX functionality, so I thought I’d crank out one more blog post. The basic approach is similar to the one I describe here. Using the same Adventure Works data, I can load the DimDate and FactInternetSales tables into PowerPivot V2.0 and I’ll get the following model: Note that we have three relationships between the two tables: one active one, which is the relationship from OrderDateKey to DateKey, and two inactive ones from DueDateKey and ShipDateKey. If we want to find the number of orders up to the current date using the Order Date we can simply use the following DAX in a measure definition: SalesToDate:=CALCULATE( Now, if we want to find the number of orders that have shipped up until yesterday we don’t need any special modelling, we can use the new UseRelationship function to force a calculation to follow the relationship going from ShipDateKey to DateKey. Therefore, if we want to find the number of orders that have been placed but not shipped, we just need to take the measure above and subtract the vale returned by the same measure when use this different relationship and change the filter context to be the day before the current day: SalesInProgress:=[SalesToDate]- Quite an elegant solution, I think.
|
Author articles
- Controlling the Position of Subtotals in DAX with GenerateAll()
- Self-Service BI Mapping with Microsoft Research’s Layerscape–Part 2
- Self-Service BI Mapping with Microsoft Research’s Layerscape–Part 1
- Aliasing Columns in DAX
- Using Google Docs, Data Explorer and PowerPivot for Questionnaires
Most Popular
- Step by step guide on installing PowerPivot for SharePoint on a single machine
- List of suggested datasets to test PowerPivot
- List of PowerPivot DAX functions with description
- How to install PowerPivot for Excel and list of know issues
- Microsoft Virtual Lab: PowerPivot for Excel 2010 Introduction
- List of PowerPivot DAX functions (short)
- Learning PowerPivot and DAX
- PowerPivot's impact on BI pros?



