MDX Solutions Sample Chapter
Who’s going to PASS Europe next week?
AddCalculatedMembers bug
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=248868&SiteID=1
Basically there’s a bug in the AddCalculatedMembers function which means that it brings back calculated members which it shouldn’t actually bring back. Since AddCalculatedMembers isn’t the most widely used function you’d think it wouldn’t have much impact, but one area that it might cause a problem is when client tools issue MDX queries to get metadata for display purposes – a fairly widely used technique. So, for example, in AdventureWorks if you added the following calculated member definition to the cube’s MDX Script and then deployed:
CREATE MEMBER CURRENTCUBE.[Product].[Product Categories].[Category].&[4].[BugTest]
AS 999, VISIBLE = 1 ;
You’d expect the calculated member to appear only underneath the Category ‘Accessories’ when you browsed the Product Categories hierarchy in the treeview in BIDS. However, what actually happens is that the calculated member appears underneath every category in the hierarchy and not just the one you wanted, which is pretty irritating, and this doesn’t just happen in BIDS – it happens in SQLMS, the Microsoft Excel Addin, and even Proclarity (reportedly), although it doesn’t happen in Office 12 beta or Panorama.
Running a Profiler trace while using SQLMS reveals what the problem is. When expanding ‘Bikes’ in the treeview it shows the following MDX being run:
SELECT
SUBSET( ADDCALCULATEDMEMBERS( [Product].[Product Categories].[Category].&[1].CHILDREN ), 0, 501 )
DIMENSION PROPERTIES MEMBER_NAME, MEMBER_TYPE ON 0,
{} ON 1 FROM [Adventure Works]
Nigel Pendse is doing his own podcasts
URL Encoding in MDX
WITH
MEMBER MEASURES.TESTAS URLESCAPEFRAGMENT("[Geography].[City].&[Abingdon]&[ENG]")
SELECT MEASURES.TEST ON 0
FROM [Adventure Works]
%5bGeography%5d.%5bCity%5d.%26%5bAbingdon%5d%26%5bENG%5d
BI Pathfinder
ascmd tool beta
MDX Limericks
Here are the rules:
- Each entry must be an MDX query executable against any cube/perspective in the Adventure Works database, and must take the form of a limerick (see http://en.wikipedia.org/wiki/Limerick_(poetry for details)
- The query must return at least one cell which contains a value other than null
- Entries should be posted as comments to this blog entry
- Extra points will be awarded for wit and creativity
It’s actually pretty difficult. Here’s my first attempt:
WITH MEMBER [Date].[Day Name].[TODAY]
AS 1 + [Date].[Day Name].[THURSDAY]
SELECT [Average Rate]
ON 0, [Date].[Date]
ON 1 FROM [Direct Sales] WHERE([MAY])
As an aside, this brings up the vexed question of how you should pronounce MDX. In my limerick I’m not pronouncing the punctuation so it reads:
WITH MEMBER DATE DAY NAME TODAY,
AS ONE PLUS DATE DAY NAME THURSDAY,
SELECT AVERAGE RATE,
ON ZERO, DATE DATE,
ON ONE FROM DIRECT SALES WHERE MAY.
However I’m prepared to be flexible on this point.
So come on all of you (and especially you Jon, as I know you can never resist something like this) and get composing!
UPDATE: I’ve decided two rule changes, to make things easier. First I’ll allow queries from Foodmart 2000 for those of you on AS2K; second I’ll allow statements other than SELECT statements (eg CREATE SET, UPDATE CUBE etc) so long as they execute without errors.
The StrTo functions and CONSTRAINED
- StrToMember can only take a string containing a member name
- StrToSet can only take an explicitly defined set, ie a list of member names or tuples in curly brackets
- StrToTuple can only take an explicitly defined tuple, ie a list of member names in brackets
- StrToValue can only take a constant value
WITH
MEMBER
MEASURES.STRTOSET_TEST1 AS COUNT(STRTOSET("{[Measures].[Internet Order Quantity]}"))MEMBER
MEASURES.STRTOSET_TEST2 AS COUNT(STRTOSET("MEASURES.MEMBERS"))MEMBER
MEASURES.STRTOSET_TEST3 AS COUNT(STRTOSET("{[Measures].[Internet Order Quantity]}", CONSTRAINED))MEMBER
MEASURES.STRTOSET_TEST4 AS COUNT(STRTOSET("MEASURES.MEMBERS", CONSTRAINED))SELECT
{MEASURES.STRTOSET_TEST1, MEASURES.STRTOSET_TEST2, MEASURES.STRTOSET_TEST3, MEASURES.STRTOSET_TEST4} ON 0FROM
[ADVENTURE WORKS]