Currently I have the following calculation to get the closing Inventory balance for a year
Code Snippet
([Measures].[Total Square Area], ClosingPeriod([Time].[Quarter].[Quarter]))But for 2007 for example this is Empty as Q4 has no data.
I know there must be a simple way to return the Last NON EMPTY Quarter's balance but I am having a fog on it....
Any help or link to an example would be great!
Will
Maybe this will work:
Code Snippet
([Measures].[Total Square Area],
Tail(NonEmpty([Time].[Quarter].[Quarter],
[Measures].[Total Square Area])).Item(0))
|||Hi Deepak,
Unfortunately that returns an error
"Token Error, Syntax is not valid"
I figured it must be close though
|||Well, here's a sample Adventure Works query, based on the above code snippet, which returns the last populated Quarter Exchange Rate for DeutscheMarks in FY2002 - a value of .49 in FY2002Q2 (after which the Euro replaced the DM):
Code Snippet
With
Member [Measures].[QuarterExchange] as
([Measures].[Average Rate],
Tail(NonEmpty(
[Date].[Fiscal Quarter of Year].[Fiscal Quarter of Year],
[Measures].[Average Rate])).Item(0)),
FORMAT_STRING = '#.00'
select
{[Measures].[QuarterExchange]} on 0
from [Adventure Works]
where ([Date].[Fiscal].[Fiscal Year].&[2002],
[Destination Currency].[Destination Currency].&[Deutsche Mark])
-
QuarterExchange
.49
Hi Will,
Yes, this is new in AS 2005 - in AS 2000, you could try NonEmptyCrossJoin(), like:
Code Snippet
([Measures].[Total Square Area],
Tail(NonEmptyCrossJoin([Time].[Quarter].Members,
{[Measures].[Total Square Area]}, 1)).Item(0).Item(0))
For future reference, you might want to mention explicitly that you're asking a question specific to AS 2000, given that SQL Server 2005 was launched nearly 2 years ago, and we're on the threshold of SQL Server 2008
MDX: NonEmpty, Exists and evil NonEmptyCrossJoin
|||Hi,
Thanks - sorry about the confusion with versions...
I was using 2005 at my old place. No I am 2005 for SSIS & SSRS but they won't budge from 2000 for AS just yet so it's a real pain & I tend to forget to mention it.
Sorry, & thanks for the help
No comments:
Post a Comment