Ragged Hierarchies, HideMemberIf and MDX Compatibility
Here’s something that I suspect a few people out there will be surprised I didn’t know – but as far as I’m concerned, if I didn’t know it then it’s worth blogging about.
Anyway, it regards ragged hierarchies, the HideMemberIf property and the MDX Compatibility connection string property. Now you probably know that if you want to turn a user hierarchy into a ragged hierarchy (perhaps to avoid using a parent child hierarchy) you need to use the HideMemberIf property on the user hierarchy. For example, imagine you were using the following SQL query as the basis of your customer dimension:
SELECT ‘UK’ AS Country, ‘Bucks’ AS State, ‘Amersham’ AS City, ‘Chris Webb’ AS Customer
UNION ALL
SELECT ‘Italy’ AS Country, ‘BI’ AS State, ‘Biella’ AS City, ‘Alberto Ferrari’ AS customer
UNION ALL
SELECT ‘Vatican’ AS Country, ‘Vatican’ AS State, ‘Vatican’ AS City, ‘The Pope’ AS customer
We could build a dimension off this with attributes for Country, State, City and Customer, and for two out of our three customers that would be fine. However the Pope lives in the Vatican, which is (at least for the purposes of this exercise) a Country with no concept of City or State; and in the case of customers who live in the Vatican, we just want to be able to drill down on the Country ‘Vatican’ and see all of the Customers who live there without drilling down through a meaningless State and a City.
So what we can do is build a user hierarchy on our dimension with levels Country, State, City and Customer, and on the lower three levels set the HideMemberIf property to OnlyChildWithParentName:
Then, with any sensible client tool, we can connect to the cube and browse the dimension as we want:
I saw ‘sensible’ client tool, because of course this only works if you set:
MDX Compatibility=2
…in the connection string. And of course Excel 2007 hard-codes MDX Compatibility=1 in the connection string and doesn’t allow you to change it, so you can’t use ragged hierarchies properly.
This much I knew.
However, what I didn’t realise until last week when I was moaning about this to TK Anand from the SSAS dev team at PASS, is that for some ragged hierarchies you don’t need to set the MDX Compatibility connection string property at all.
For example, if in our case we duplicate the Customer upwards rather than the Country downwards, like so:
SELECT ‘UK’ AS Country, ‘Bucks’ AS State, ‘Amersham’ AS City, ‘Chris Webb’ AS Customer
UNION ALL
SELECT ‘Italy’ AS Country, ‘BI’ AS State, ‘Biella’ AS City, ‘Alberto Ferrari’ AS customer
UNION ALL
SELECT ‘Vatican’ AS Country, ‘The Pope’ AS State, ‘The Pope’ AS City, ‘The Pope’ AS customer
…and then build the dimension, setting HideMemberIf on our user hierarchy to OnlyChildWithParentName, we can get the result we want without setting the MDX Compatibility property. Here’s a screenshot of this new dimension in Excel just to prove it:
The difference here is that we’re hiding all members below the State level right down to the bottom of the hierarchy, rather than hiding members somewhere in the middle of the hierarchy. Truly, this is one of those “Doh, if only I’d known!” moments… this at least means that in some of the scenarios where you’d use ragged hierarchies you can get them to work with Excel, even if it means that we have to hack the data (‘The Pope’ is a Customer, not a State or a City). On the other hand there are plenty of scenarios where you do need to hide members in the middle of a hierarchy, and frankly I don’t see why Excel 2007 can’t set MDX Compatibility=2 in its connection string so they work properly.




Good article, happy to read it: I was discussing this fact last week with one of my colleagues, an d I thought I was becoming crazy or something. I think we have no alternative except always putting the "repeating" data on the bottom of the hierarchy. I\’ve tested on several SSAS versions and the problem seems to be quite old. Nevertheless thanks for this!
François
November 12, 2009 at 9:39 am
Hi, Chris. By coincidence I was researching this exact issue yesterday and came upon this post: http://social.msdn.microsoft.com/forums/en-US/sqlanalysisservices/thread/2a36d561-fdea-4b78-8d5f-3d383ed6d6a1I tested furmangg\’s "mystical" suggestion (adding Extended Properties="MDX Compatibility=2";MDX Compatibility=2; to the Excel connection string) and it worked…kind of…Members were hidden but all members below the hidden members (even if they did not meet the HideMemberIf condition) were also hidden. Using your first example, you\’d get Vatican with no children at all. Not what I expected…
Brian
November 12, 2009 at 10:17 pm
Hi Chris!
It’s really a stupid thing..
Just a note… your solution work if you have oneToMany relation inside dimension, right?
regards,
Pedro
PedroCGD
October 19, 2010 at 11:05 pm
What do you mean by a ‘one to many’ relationship? Do you mean attribute relationships? In any case, the solution should work for all dimensions.
Chris Webb
October 20, 2010 at 12:43 pm
Chris, Thanks for the article. I followed your example above on 2008R2 and while browsing the hierarchy in the dimension browser, the state and City are not being hidden. What i see is
Vatican->Vatican->Vatican->The Pope. Any advice please!
Sam
November 19, 2010 at 6:41 pm
What do you see in Excel?
Chris Webb
November 20, 2010 at 10:31 pm
It’s the same in excel aswell. It works only if all the levels can be hidden as in Vatican->The Pope->The Pope->The Pope. But in my case that’s not possible…
Sam
November 22, 2010 at 3:19 pm
I’ve just tried this on my R2 instance, and it’s working fine. Can you check your data and that you’ve set everything up correctly?
Chris Webb
November 24, 2010 at 1:19 pm
Ah, hold on, I’ve just read your comments properly – yes, the whole problem is that if you do Vatican-Vatican-Vatican-The Pope, then you can’t get this to work in Excel or in the browser. This approach will only work if you can set the MDX Compatilibility property, which isn’t possible in Excel. You’ll have to remodel your data if you do want it to work.
Chris Webb
November 24, 2010 at 1:21 pm
Hi Chris,
Do you mean BIDS browser is not ‘sensible’?
I can accept Excel not be able to display this property, but BIDS browser…???
How can it be possible BIDS browser can’t display its own properties?
Thanks in advance.
pitix
November 3, 2011 at 2:28 pm
I know, I know. But it’s true – the BIDS browser doesn’t do this.
Chris Webb
November 4, 2011 at 9:15 am
Thanks Chris!
Sam
November 29, 2010 at 4:47 pm
Hi Chris,
I’m looking at using this approach but SSAS R2 Books Online say that HideMemberIf is being deprecated in the next version. As this is the only real way to get pre-aggregated data into a cube without using P/C do you have any idea what it is going to be replaced with?
David
David
December 22, 2010 at 1:10 pm
Hi David,
It’s not true that HideMemberIf is being deprecated – I’ve seen that before and asked the dev team, and BOL is wrong. So feel free to use it.
Chris
Chris Webb
December 22, 2010 at 5:14 pm
Hi Chris,
I am trying to do something similar with an organisation structure dimension. I have eventually written a stored proc. to manually remove the spaces/repeats at each level. Now I have my ragged hierarchy how do I get it to display correctly in SSRS? I can see it perfectly in Excel pivot table but SSRS is a different matter. Only branches that extend to the last level are displayed. Even a Parent/child hierarchy does not display properly in SSRS. If the answer is too long perhaps you know of a good resource? Thanks for a good article! Matt.
Matt
January 4, 2011 at 7:12 pm
Hi Matt, this is a tricky one – I suspect the best answer would be not to use ‘traditional’ SSRS drilldown at all, but instead use an approach like the one I describe here: http://cwebbbi.wordpress.com/2009/02/16/implementing-real-analysis-services-drilldown-in-a-reporting-services-report/
… but I’ll have a think about it and get back to you.
Chris Webb
January 4, 2011 at 7:46 pm
[...] http://cwebbbi.wordpress.com/2009/11/11/ragged-hierarchies-hidememberif-and-mdx-compatibility/ [...]
Flattening or “Naturalizing” a parent-child hierarchy | jsimonbi
January 16, 2011 at 9:26 am
I could probably comment on every single post you make, Chris, but this one was particularly helpful today! Thanks for helping me navigate the wild, wacky world of Microsoft BI.
Shawn
April 1, 2011 at 12:48 am
Hi Chris,
Great article. Still struggling to get a ragged hierarchy to display as expected. Take the example below:
Level 1->Level 2-> Null/Empty -> Level 3 -> Leaf Level
As per the notes I can get things working if I repeat the ‘Leaf Level’ up the parent levels and set [HideMemeberIf] to ‘OnlyChildWithParentName’.
However, if in my case I need to hide the level below 2. Setting the [HideMemeberIf] to ‘NoName’ does not appear to work. Any ideas?
Can you also please explain where I can set MDX Compatibility in SSAS dimension browser and in the PerformancePoint data source.
Thanks in advance
Mo Bhatti
June 3, 2011 at 9:14 am
The point is you can’t use a null value – you need to copy the value from Level 3 up if you want to avoid using the MDX Compatibility property (you should also avoid using null values because it will stop you building effective attribute relationships). You can’t set MDX compatibility in the dimension browser; I’ve not tried, but you should be able to add it to the connection string in the connection object in PerformancePoint.
Chris Webb
June 3, 2011 at 9:21 am
I tried the following:
1) Method #1
Level 1-> Level 2-> Level 3 -> Level 3 -> Leaf Level
[HideMemeberIf]=’ParentName’ for all levels.
2) Method #2
Level 1-> Level 2-> Empty -> Empty -> Leaf Level
[HideMemeberIf]=’NoName’ for all levels. Empty refers to empty strings, i.e. ”, .
I guess what has been confusing me is that you cannot see the true results in the dimension or cube browser.
What’s the easiest of visually checking if the ragged hierarchies are working as expected?
Mo Bhatti
June 3, 2011 at 9:53 am
You can manually alter the connection string that Excel uses.
Chris Webb
June 3, 2011 at 9:56 am
Thanks for your help. I will give a whirl in Excel.
It’s a real shame that the cube browser or dimension browser do not show ragged hierarchies appropriately. Can’t imagine why we need to go to Excel.
Mo Bhatti
June 3, 2011 at 10:43 am
Hi Bhatti,
i also getting the same result like it is coming repeating level if we put that property.
chris can u tel me where to set mdxcompatability to 2
thanks in advance
Vamshi
August 3, 2011 at 10:21 am
You need to set it in the connection string you use to connect to SSAS
Chris Webb
August 6, 2011 at 8:23 pm
[...] http://cwebbbi.wordpress.com/2009/11/11/ragged-hierarchies-hidememberif-and-mdx-compatibility/ [...]
SSIS Balanced and Unbalanced Dimensions « Sladescross's Blog
January 24, 2012 at 2:59 pm
Hello Chris,
Nice post and regarding this topic, I am also drilling somewhat like this as Can we hide the Dimension Hierarchy level ?
I have open a thread on this too
http://social.msdn.microsoft.com/Forums/en-US/sqlanalysisservices/thread/9692a772-c503-4968-b9b5-c8e2344b9b7b?prof=required
Hope to hear from you.
Thanks,
Anil Maharjan
Anil
March 29, 2012 at 12:31 pm
Hi Chris,
I have the following data:
- Project1 is parent of itself and Project2
- There are hours related to projects, in this case only 5 hours were spend at Project1, none at Project2.
Flat data looks like: (like in SQL with project LEFT join hours):
Parent – Project – Hours
Project1 – Project1 – 5
Project1 – Project2 – NULL
If I put this in a cube and set the HideMemberIf property to OnlyChildWithParentName and look at it in Excel, I get the following:
Project1 – Project1 – 5
Project2 isn’t shown because it has no hours. But since Project1 is the only one shown, I want level2 to be hidden; because it -optically- validates to OnlyChildWithParentName (though in the dimension it’s not true).
Is this ‘works as designed’ or is there something I’m missing?
Thanks in advance!
Regards,
Lars Pauwels
Lars Pauwels
August 29, 2012 at 9:12 am
That’s not working as it should be – have you set HideMemberIf on the correct level?
Chris Webb
August 29, 2012 at 10:19 am
Thnx for your quick response.
The hierarchy is: Parent – Project, I’ve set the property on Project (not on Parent because it’s the highest level and I never want to hide that).
Lars Pauwels
August 29, 2012 at 10:36 am
Can you try setting it on both levels to see what happens?
Chris Webb
August 29, 2012 at 10:38 am
Makes no difference…
By the looks of it, it seems he builds the hierarchy first including the HideMemberIf property AND THEN eliminates the rows that have no measures associated, but fails to look back if he can ‘redo’ the HideMemberIfProperty…
Lars Pauwels
August 29, 2012 at 10:44 am
No, that’s not the case – something else must be wrong here. What happens when you browse the dimension in the dimension editor?
Chris Webb
August 29, 2012 at 1:02 pm
Like I expect:
- All
– Project1
Project1
Project2
Lars Pauwels
August 29, 2012 at 1:06 pm