sql - Last non-empty child over period using MDX -


[edit: example not entirely correct]

i've been pulling hair out on mdx issue... making cube concerning billing.

i have 2 (relevant) dimensions: budgetbill , month
, 1 measure: amount

budgetbill date         amount 1548632    2012-11-04   50 1548632    2012-11-23   40  <-- 1548632    2012-12-16   70  <--  1724687    2012-10-02   120 1724687    2012-10-23   170 1724687    2012-10-89   200  <--  total                   310 

i have date hierarchy [bb updatedate]

year - quarter - month - week - date

so need have last amount per month, on budgetbill.
in above example 40 + 70 + 200 = 310

one of mdx code snippets i've tried

with member [measures].[test] sum(tail(nonempty(descendants([bb updatedate].[bb updatedate hierarchy].currentmember, [bb updatedate].[month]) ,[measures].[amount]), 1),[measures].[amount])  select [measures].[test] on columns ,nonempty([bb updatedate].[month]) on rows [budgetbill] {[budgetbill].[budgetbillnr].&[1548632],[budgetbill].[budgetbill].&[1724687]} 

gives 120 + 170 + 200 = 490 --> not correct... (close) example tried many things!

thanks in advance help!!

i think trick

with  member [measures].[maybe] sum( generate(     descendants([date].[bb update hierarchy].currentmember, [date].[bb update hierarchy].[month])     ,tail(         nonempty(existing [date].[bb update hierarchy].[date], [measures].[amount])     ,1) ) ,[measures].[amount]) 

hope helps


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -