Hierarchies in PowerPivot
Posted by denglishbi on May 19, 2010
I saw one of Denny Lee’s tweets this morning titled “Hierarchies, Oh Hierarchies…where are thou? (in PowerPivot)”, so I was intrigued since I just talked about this not being available yesterday in my PASSMN presentation. In his example that he provided was two tables, one for the list of states and another with the city names along with the corresponding state id value reference, and he showed how even though you can relate the two tables that the results could be misleading. If you tried to select the state name and then city name the city name would actually be replicated for each state. Not what you would expect.
As a work around for this solution he suggested to add a fact table and once that was created then you would see the expected results and the cities would be mapped to the respective states. My thought was to simply add a calculated column in the city table that had the state id mapping. So the tables would look like such:
So initially the StateName column did not exist in the city state table I had defined, but once the relationship was in place I simply added a new calculated column in the table using the RELATED DAX function to pull in the state name associated with the cities (see the DAX function in the formula bar in the middle screenshot). Now you can provide the single table for the end-users to reference and they will get the following results:
The good thing about this is that you don’t necessarily need to display the state table anymore since the information is included in the city state table and the end-users will know that the columns are truly related to each other since they are in a single table. Still doesn’t exactly make sense why it didn’t work out-of-the-box originally without the fact table solution that Denny provided, but the calculated column solution takes care of the issue, plus provides the single denormalized table that we would typically see for geography information in this instance.
Now the one thing that you don’t get is the user-defined hierarchy like you have in Analysis Services (SSAS) where you would have the navigation path clearly defined for the users to be able to drag-and-drop and drill down (or up). So when I state that hierarchies are not available this is what I am referring to.