[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Mdx count measures

Posted on 2009-03-30
2
Medium Priority
?
773 Views
Last Modified: 2013-11-16
I want made a measures that count days between two dates, but the first date is same (2007-08-31), but the second is now or the fact's last date .

i have:
count([Time].[Date].&[2007-08-31T00:00:00]:[Time].[Date].&[2009-03-18T00:00:00])

i want :

count([Time].[Date].&[2007-08-31T00:00:00]: now)      -  [b]error[/b]

count([Time].[Date].&[2007-08-31T00:00:00]: Tail(NonEmpty([Time].[Year -  Month -  Date].Members,[Measures].[qty] )).item(0).membervalue )      -[b]  error[/b]

Do you know how I can do it?

thanks
0
Comment
Question by:rauljimenez
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 12

Expert Comment

by:RWrigley
ID: 24020063
The closingperiod function will give you the "last" member of the specified time level, but that may not be accurate if your cube has forward looking dates:

select
closingperiod ([Date].[Calendar].[Date]) on Rows,
[Measures].[Internet Sales Amount] on Columns
from [Adventure Works]


A more robust solution is to generate a set filtered on a measure that you know only has values for current dates, and then take the last member of that:

select
tail(filter([Date].[Calendar].[Date],[Measures].[Internet Sales Amount] <> NULL),1) on Rows,
[Measures].[Internet Sales Amount] on columns
from [Adventure Works]

A similar approach is to define an attribute flag in your time dimension that will indicate the current day.  However, this is only practical if you're updating the cube every day.
0
 
LVL 12

Accepted Solution

by:
RWrigley earned 2000 total points
ID: 24020471
Here's an Adventure works example:
WITH MEMBER [Date].[Calendar].[COG_OQP_USR_Count(Last)] AS 
'
COUNT(
 EXCEPT(
  PERIODSTODATE(
    [Date].[Calendar].[(All)], 
    TAIL(
      FILTER(
       {[Date].[Calendar].[Date].MEMBERS}, 
       NOT ISEMPTY([Measures].[Internet Order Quantity]
      )
     ), 
     1
    ).ITEM(0).ITEM(0)
   ), 
   PERIODSTODATE(
    [Date].[Calendar].[(All)], 
    TAIL(
     FILTER(
      {[Date].[Calendar].[Date].MEMBERS}, 
      NOT ISEMPTY([Measures].[Internet Order Quantity]
     )
    ), 
    1
   ).ITEM(0).ITEM(0).LAG(12)
  )
 ), 
 INCLUDEEMPTY
)', 
SOLVE_ORDER = 4, FORMAT_STRING = "#" 
 
SELECT 
	{[Measures].[Internet Order Quantity]} ON Rows, 
	{[Date].[Calendar].[COG_OQP_USR_Count(Last)]} ON Columns 
FROM [Adventure Works]  

Open in new window

0

Featured Post

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
Lotus Notes has been used since a very long time as an e-mail client and is very popular because of it's unmatched security. In this article we are going to learn about  RRV Bucket corruption and understand various methods to Fix "RRV Bucket Corrupt…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question