dbTalk Databases Forums  

Problem with CoalesceEmpty

microsoft.public.sqlserver.olap microsoft.public.sqlserver.olap


Discuss Problem with CoalesceEmpty in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Peter
 
Posts: n/a

Default Problem with CoalesceEmpty - 09-09-2005 , 01:01 AM






Hi,
I am having a nightmare with this inventory scenario.

Seemingly simple. All I am trying to do is find a "Last Non Empty
Balance". I've read the microsoft paper and just about everything else
I can find but I'm still stuck.

I have the following formula for "Last Non Empty Value"

CoalesceEmpty((Measures.[IC Close OnHand Qty], [Sales
Period].currentmember) ,

(Measures.[Last Non Empty Value],[Sales
Period].CurrentMember.PrevMember))

which works great in some instances. In some cases however AS returns a
"Internal Error". I think this is because there is no balance at all
for some products and the reference to "prevmember" fails.

At which I thought that rather than simply call itself with prevmember
i should check first ie.

CoalesceEmpty((Measures.[IC Close OnHand Qty], [Sales
Period].currentmember) ,
iif([Sales Period].currentmember is head([Sales
Period].currentmember.level.members).item(0),0,

(Measures.[Last Non Empty Value],[Sales
Period].CurrentMember.PrevMember)))

Which had no affect at all.

I also have "NON EMPTY" in my query so then I though it might be that
the check for first is wrong because the first member available is not
necessarily the first on that level because some members have been
eliminated.

If so, how do I do this check.

Note that if I force an first 0 entry for every products, it all seems
to work fine, but I don't want to do this because of the volume.

Any help gratefully received!!

Thanks.

What am I doing wrong?


Reply With Quote
  #2  
Old   
pras
 
Posts: n/a

Default Re: Problem with CoalesceEmpty - 09-09-2005 , 01:40 AM






Try using trail with Filter command to see the last non empty value


Reply With Quote
  #3  
Old   
Peter
 
Posts: n/a

Default Re: Problem with CoalesceEmpty - 09-09-2005 , 01:51 AM



How? sorry i'm not sure how the filter would look, given that my user
could have any sort of filters on the report (in the MDX)?


Reply With Quote
  #4  
Old   
pras
 
Posts: n/a

Default Re: Problem with CoalesceEmpty - 09-09-2005 , 02:17 AM



Try something like this

Tail(Filter(Descendants([Sales
Period].currentmember),([Measures].[Unit Sales])>0),1).item(0)

Let me know if it works for you

Regards,
Prasanna


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.