ReportPortal
ReportPortal
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ReportPortal General Forum
 Report Portal General Issues
 MDX datediff query
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

dbooth

United Kingdom
69 Posts

Posted - 12/19/2012 :  08:01:59  Show Profile  Reply with Quote
A calculated measure with MDX "datediff ("d",[Collection Date].[Date],now())" is returning a huge number - 734855 - for all records.

The Date dimension has a surrogate key with the natural key 'Date' identified in SSAS as the Name column for the surrogate. Incorporating 'Date' as a row in a report correctly shows the date.

Is there an error in the MDX above or is it due to using a surrogate key on the Date dimension?

admin

1637 Posts

Posted - 12/19/2012 :  13:43:44  Show Profile  Reply with Quote
When you don’t specify the [Collection Date].[Date] on filters, rows or columns it will be set to the default member (All Collection Dates). The DateDiff will net be able to convert “All Collection Dates” to a date.

Your MDX expression should check if the text is a date like:

Iif(IsDate([Collection Date].[Date].CurrentMember.Name),
datediff ("d",[Collection Date].[Date].CurrentMember.Name,now()), 0)
Go to Top of Page

dbooth

United Kingdom
69 Posts

Posted - 12/19/2012 :  16:00:28  Show Profile  Reply with Quote
That worked perfectly, thank you. Is there a book or other resource you can recommend for this level of MDX?
Go to Top of Page

admin

1637 Posts

Posted - 12/19/2012 :  20:11:59  Show Profile  Reply with Quote
Fast Track to MDX

http://www.amazon.com/Fast-Track-MDX-Mark-Whitehorn/dp/1846281741
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
ReportPortal © 2000-2002 Snitz Communications Go To Top Of Page