Reputation: 1840
I'm trying to create a cube with a single measure. This measure is a distinct count of a "name" column. The cube works perfectly if the measure is set to "count" type. However when I set distinct count I get this error:
"Errors in the OLAP storage engine: The sort order specified for distinct count records is incorrect"
I have read in some blogs that you can only have a distinct count on a numeric column. I can't see a good reason for this, and I can't find that info on official documentation. However, it may be true. Anyways, I'm really stuck with this issue. What are my options?
Upvotes: 2
Views: 9370
Reputation: 889
I was facing the same problem and I found that there were special characters/symbols in my data which prevented from processing the cube. Most probably, the cube was unable to sort data with special characters.
I was able to solve the issue by converting the data into hashbyte string using following function:
SUBSTRING(master.dbo.fn_varbintohexstr(HashBytes('MD5', [column_name])), 3, 32)
Upvotes: 0
Reputation: 11
Derby provided the correct answer in my situation. In my case, I was trying to process a Mining Model in SSDT (VS 2012) and I was getting the error.
The error began after I made some corrections to a query that generated a table I used as my data source. My guess is that it introduced some NULLS somewhere that I did not have before I made the corrections to my query, and therefore source table (the Mining Model processed just fine before that). I am unable to vote up Derby due to my noob reputation.
Upvotes: 0
Reputation: 5415
I had this problem trying to make a distinct count on an INT ID column. After spending ages looking at Unknown Member settings and dimension usage settings, I found another suggestion that Distinct Count measures don't like NULL values. Adding WHERE COLUMN IS NOT NULL to the partition queries for this distinct count measure group solved my issue.
This was the suggestion: "Errors in the OLAP storage engine: The sort order specified for distinct count records is incorrect.
Check that the distinctcount column does not contain nulls. If it does, these can be omitted from the measure group via a query in the partition definition (assuming the distinct count measure is in its own measure group)"
Upvotes: 1
Reputation: 71
Google and in particular Eggheadcafe came to the rescue with a solution:
Upvotes: 3
Reputation:
my answer may be too late for you, but hope this can help other which have the same problem.
This solution is from this link http://www.bi-dw.info/sql-server-tips/distinct_count-measure-on-uniqueidentifier.htm
Upvotes: 8
Reputation:
It can be due to the collation settings. Sql server has by default SQL_Latin1_General_CP1_CI_AS where as the SSAS uses the Windows Collation Latin1_General. If you change the collation on the column on which you are doing the distinct count i think will solve the problem
Upvotes: 0
Reputation: 1940
You are right, you can do a distinct count on an nvarchar column.
It could be something to do with strange characters or with your collation setting.
You could try processing smaller subsets of the measure group to try and isolate a problem row.
Upvotes: 0
Reputation: 1840
I will answer myself, maybe this is helpful for somebody else.
The short answer is YES.
I have created some test tables with the same structure but just a few test rows. The cube works perfectly with this data.
So, I guess there are some corrupt data on the original tables, or maybe some rare chars.
Upvotes: 0