“Internal error: An unexpected exception occurred.” when trying to filter simple dimension that has ragged parent-child hierarchy in multidimensional model.

This issue is not resolved yet. I am describing the problem here to get help from the community. There is also a question asked on Stack Overflow and bug reported to the Microsoft.

Platform: SQL Server Analysis Services 2016 RTM and later (Multidimensional)

 

In one of our projects, we encountered an interesting problem related to parameter filtering on one of our reports (SSRS). However, we would like to make sure that no mistake has been made before it hits as a bug for Microsoft.

 

In the database we have the following dimension of companies:

The parent-child hierarchy does not loop but it’s ragged. The graph looks as follows (treant-js drawing):

 

The Analysis Services project contains only one dimension – Company, created using the wizard. All settings are set with default values. “CompanySK” is the KeyColumn and “CompanyName” is the NameColumn. “CompanyParentSK” was renamed to “Company Hierarchy” and Usage was set to “Parent”, which indicates this attribute holds parent id. Nothing unusual:

 

To make it possible to query this data as Reporting Services is doing, the cube was created with just one simple measure: count of Companies. Bear in mind, that this measure is irrelevant to us, we will not query it.

 

The project is always loaded and processed without problems.

The hierarchy works and is represented correctly in the tree viewer (SSMS). Because “MembersWithData” is set to “NonLeafDataVisible” (by default), you can see repeated company names of every parent in his child list.

 

Now we need to query the Dimension using MDX. This query simulates Reporting Services Parameters Query so it always get MEMBER_CAPTION, UNIQUENAME and LEVEL.ORDINAL. 

In our report Companies were listed only by selecting Countries first, so the country parameter is always filtering companies and it’s doing it by using STRTOSET([members selected in the previous parameter]) function in WHERE clause. 

 

When you try to list all Companies where “Country Name” is “Germany”:

it returns an error:

 

Executing the query …

Internal error: An unexpected exception occurred.

Run complete

 

BUT if you will ask for Australia:

or United Kingdom

it just works:

 

 

The problem becomes more strange when you will try to make any combinations of available countries. For example “United Kingdom” and “Australia” filtered together – are making the query always failing:

 

And now the interesting facts:

  • If you will remove/comment [Measures].[ParameterCaption] from the selection – query starts to work,
  • if you will disable “Company Hierarchy” by changing it back to regular attribute – query starts to work,
  • removing the filter (WHERE) makes the query working,
  • so as you can see – even if “Company Hierarchy” is not a part of any query listed above, it affects somehow the engine and fails the query when it comes to retrieving CURRENTMEMBER.MEMBER_CAPTION on “Company Name” attribute when another attribute – “Country Name” – is filtered. And not for all filtered values, but we couldn’t find any pattern here (for example if country level affects somehow).
  • Using SQL Server Profiler (with enabled all events in capture scope) and sniffing one of the failing queries, it is clear, that the error is appearing during last phase of getting members – exactly for CURRENTMEMBER.MEMBER_CAPTION.

 

Unfortunately, we’re running out of ideas what can be wrong with this case. Is it there any setting in Visual Studio project that can help or maybe it’s just a bug in the engine? Any help would be appreciated. 

 

Of course, we’ve tried a lot of changes and checks. Let me list them here to eliminate unnecessary assumptions:

  • We have checked probably(?) every possible setting on “Company Hierarchy” and if it affects this issue (like encoding, ordering, data visible, naming template etc.) Only changing this hierarchy to regular attribute (“Usage” : “Regular” from “Parent”) is making the issue resolved and unfortunately, we would like to have this hierarchy for future analysis.
  • We have changed manually the parent-child chain to flat one – only one parent and all are children, and simple nested one – 2 is a child of 1, 3 is a child of 2 and so on and so forth. This makes the issue go away, queries are working.
  • This error does not generate any important information in the log. It is a general unknown error known also as “Type: 3, Category: 256, Event ID: 0xC1000016”. It triggers memory dumps creation.
  • We are aware of several bugs that were introduced and fixed by Microsoft in this area (parent-child), none of them apply to our case (for example we are querying using admin account, we do not use no translations etc.)
  • In fact we decided to test this case across many platforms and bugfixes, all of them failed on these SSAS versions: 2016 RTM, 2016 SP2, 2016 SP2 CU7, 2017 RTM, 2017 CU15
  • Our case was more complex, but we were able to simplify it and introduce it to you by using just a small dimension with the same hierarchy that was failing. 
  • It’s totally reproducible across different platforms (as mentioned above), different versions of Data Tools (15.9.0, 16.0.6) and Visual Studio (2017 & 2019)
  • If you would like to reproduce this in your environment, you can download the [DATABASE backup here] (or use table creation code below) and [SSAS PROJECT here]
  •  
  • And more MDX examples:
     

Leave a Reply