Hi
From my perspective the easiest way to achieve this is to incrementaly
update your Time dimension as you update your cube with monthly data; this
way, ClosingPeriod() will obviously always return the last month with data.
However if you wish to create all future (empty) periods in advance, you may
use an MDX expression that filters the months to exclude empty ones and then
get the last member with a value; I am pretty sure this can be done in many
different ways, but here's one that should work (based on the Foodmart 2000
sales cube) :
Tail({NonEmptyCrossjoin({[Time].[Month].Members},{[Measures].[Unit
Sales]},1)},1).Item(0).Item(0)
The NonEmptyCrossjoin() expression returns a set of tuples containing only
the months that have values at their intersection with an arbitrary Measure
(here, Unit Sales)
The Tail() expression returns a set made of one single tuple corresponding
to the last position in the previously filtered set (the Time dimension
being alreday ordered by design)
The first Item(0) expression extracts the single tuple from this set, and
the second one extracts the 1st (and only) member from this tuple.
HTH
Olivier MATRAT
WINSIGHT
Microsoft Gold Certified Partner for Business Intelligence
www.winsight.fr
www.olapwebhouse.com
"Rajesh" <Rajesh (AT) discussions (DOT) microsoft.com> wrote
Quote:
Hi All,
I want to get the last month that has data. If I use ClosingPeriod it
always returns the last month in month level whether or not there is data in
|
last month.
Quote:
Please suggest an alternate way to get the last month that has data.
Thanks |