Internal error: An unexpected error occurred (file 'mdmodelmd.cpp', line 2669, function 'MDModelMD::DecodeRelAttr').

Naoto 1 Reputation point
2020-12-19T03:13:56.23+00:00

Hello,

When I execute the following MDX query, I get this error:
Internal error: An unexpected error occurred (file 'mdmodelmd.cpp', line 2669, function 'MDModelMD::DecodeRelAttr').
What does this error mean and how can I avoid this?

The intent of the query is to obtain a table like this:
49559-2020-12-18-18-31-42.png
*The query results are sorted afterwards.

WITH  
  
// top  
  
SET top_category AS TOPCOUNT( [Product].[Category].[Category].Members, 2, [Measures].[Order Quantity] )   
  
SET top_subcategory AS GENERATE(  
	top_category,  
	TOPCOUNT( ([Product].[Category].CurrentMember) * [Product].[Subcategory].[Subcategory].Members, 2, [Measures].[Order Quantity] )  
)   
  
SET top_product AS GENERATE(  
	top_subcategory,  
	TOPCOUNT( ([Product].[Category].CurrentMember, [Product].[Subcategory].CurrentMember) * [Product].[Product].[Product].Members, 2, [Measures].[Order Quantity] )   
)   
  
// all  
  
SET all_category AS {[Product].[Category].[All Products]}  
  
SET all_subcategory AS top_category * {[Product].[Subcategory].[All Products]}  
  
SET all_product AS top_subcategory * {[Product].[Product].[All Products]}  
  
// other  
  
SET all_category_ AS [Product].[Category].[Category].Members   
MEMBER [Product].[Category].[other_category] AS AGGREGATE( all_category_ - top_category )  
SET other_category AS [Product].[Category].[other_category]  
  
SET all_subcategory_ AS top_category * [Product].[Subcategory].[Subcategory].Members  
MEMBER [Product].[Subcategory].[other_subcategory] AS AGGREGATE(  
	EXISTS(all_subcategory_,([Product].[Category].CurrentMember))  
	- EXISTS(top_subcategory,([Product].[Category].CurrentMember))  
)  
SET other_subcategory AS top_category * [Product].[Subcategory].[other_subcategory]  
  
SET all_product_ AS top_subcategory * [Product].[Product].[Product].Members  
MEMBER [Product].[Product].[other_product] AS AGGREGATE(  
	EXISTS(all_product_,([Product].[Category].CurrentMember, [Product].[Subcategory].CurrentMember))  
	- EXISTS(top_product,([Product].[Category].CurrentMember, [Product].[Subcategory].CurrentMember))  
)  
SET other_product AS top_subcategory * [Product].[Product].[other_product]  
  
  
SET final AS   
top_product  
+ all_category * {[Product].[Subcategory].[All Products]} * {[Product].[Product].[All Products]}  
+ other_category * {[Product].[Subcategory].[All Products]} * {[Product].[Product].[All Products]}  
+ all_subcategory * {[Product].[Product].[All Products]}  
+ other_subcategory * {[Product].[Product].[All Products]}  
+ all_product  
+ other_product  
  
SELECT  
	[Measures].[Order Quantity] ON 0,  
	NON EMPTY final ON 1  
FROM  
	[Sales]  

In the final set, it seems this line is not working well with others.
Excluding it from the query returns results.
What can be the alternative for the grand total?

+ all_category * {[Product].[Subcategory].[All Products]} * {[Product].[Product].[All Products]}  

What is confusing is that this line works well by itself like this.

SET final AS all_category * {[Product].[Subcategory].[All Products]} * {[Product].[Product].[All Products]}  

Also, if I query only category and subcategories, there isn't any error.

WITH  
  
// top  
  
SET top_category AS TOPCOUNT( [Product].[Category].[Category].Members, 2, [Measures].[Order Quantity] )   
  
SET top_subcategory AS GENERATE(  
	top_category,  
	TOPCOUNT( ([Product].[Category].CurrentMember) * [Product].[Subcategory].[Subcategory].Members, 2, [Measures].[Order Quantity] )  
)   
  
// all  
  
SET all_category AS {[Product].[Category].[All Products]}  
  
SET all_subcategory AS top_category * {[Product].[Subcategory].[All Products]}  
  
// other  
  
SET all_category_ AS [Product].[Category].[Category].Members   
MEMBER [Product].[Category].[other_category] AS AGGREGATE( all_category_ - top_category )  
SET other_category AS [Product].[Category].[other_category]  
  
SET all_subcategory_ AS top_category * [Product].[Subcategory].[Subcategory].Members  
MEMBER [Product].[Subcategory].[other_subcategory] AS AGGREGATE(  
	EXISTS(all_subcategory_,([Product].[Category].CurrentMember))  
	- EXISTS(top_subcategory,([Product].[Category].CurrentMember))  
)  
SET other_subcategory AS top_category * [Product].[Subcategory].[other_subcategory]  
  
  
SET final AS   
top_subcategory  
+ all_category * {[Product].[Subcategory].[All Products]}  
+ other_category * {[Product].[Subcategory].[All Products]}  
+ all_subcategory  
+ other_subcategory  
  
SELECT  
	[Measures].[Order Quantity] ON 0,  
	NON EMPTY final ON 1  
FROM  
	[Sales]  

Thank you for your help on this!

SSAS Version: 14.0.6.443

SQL Server Analysis Services
SQL Server Analysis Services
A Microsoft online analytical data engine used in decision support and business analytics, providing the analytical data for business reports and client applications such as Power BI, Excel, Reporting Services reports, and other data visualization tools.
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Naoto 1 Reputation point
    2020-12-19T09:14:32.103+00:00

    For example, changing the all_category set to the following avoids the error.
    However, still the explanation of the error is much appreciated.

    MEMBER [Product].[Category].[total] AS [Product].[Category].[All Products]
    SET all_category AS [Product].[Category].[total]
    
    0 comments No comments

  2. Lukas Yu -MSFT 5,826 Reputation points
    2020-12-22T09:32:27.797+00:00

    Gladly you seems have worked around this issue! :)
    I did some googling, and could not find any information about mdmodelmd.cpp. It looks quite mysterious and out of my experience. Hope some experts could see this and offer some insight.


  3. Pavle 0 Reputation points
    2025-12-12T09:19:44.4333333+00:00

    Reprocessing the cube solved the issue for me. I'm assuming cube files were corrupted after windows update on the server

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.