O'Reilly logo

MDX with Microsoft SQL Server 2008 R2 Analysis Services: Cookbook by Tomislav Piasevoli

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Calculating today's date using an attribute hierarchy

The third way to calculate today's date is by using an attribute hierarchy. This is potentially the best way.

Instead of all the complexity with sets, strings, and other things in the previous two recipes, here we simply add a new column to the Date table and have the ETL maintain a flag for today's date. Then we slice by that attribute instead of using the Now() function in MDX. Plus, we don't have to wait to switch to "tomorrow" in MDX queries until the ETL completes and the cube is processed.

Getting ready

Open the Adventure Works DW 2008 solution in BIDS. Double-click the Adventure Works DW data source view. Locate the Date dimension in the left Tables pane and click on it.

How to do it... ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required