Monday, 15 June 2009

SSAS: Current Month in Cube

A named set which resolves the "current month" is very useful when building reports because the report can reference the named set rather than an individual month, which would need to be continually changed. Here is a piece of MDX code which returns the last month in the database which contains data.
Current Month = Tail( Filter( [Time].[Month].Members, Not IsEmpty([Time].CurrentMember)), 1)
Note: If you want to set the time dimension's "default member" to use the "current month" you will need to include .item(0) at the end of the statement to convert the set to an individual member.
The tips provided here have no implied warranty. They are provided as a free service and are informational in nature.

No comments:

Post a Comment