“重复的属性键”当属性不是键时出错
处理维度时出现以下错误:
OLAP 存储引擎中出现错误:重复的属性键已被删除 处理时发现:表:'dbo_Orders',列:'Project',值: “客户服务的东西”。属性是“项目”。
“项目”是“订单”维度的属性,但不是键。我没有在任何地方指出“项目”栏是关键!我应该能够根据需要拥有尽可能多的重复项,就像名字字段一样。
我是 Analysis Services 项目的新手,确实需要克服 SSAS 不断抱怨重复值的事实,而实际上拥有重复值应该是完全可以的。我确信这一定是我忽略的简单事情。
编辑:我意识到可以设置KeyDuplicate = ReportAndContinue/ReportAndStop
,也可以设置KeyColumns
和NameColumns
。但这个多步骤过程对于看似非常正常的操作来说似乎非常麻烦,例如添加 Address1、Address2、Address3、Firstname、Zipcode 和其他通常重复的字段。我不敢相信这个繁琐的过程需要应用于所有这样的领域?
I am getting the following error when processing a Dimension:
Errors in the OLAP storage engine: A duplicate attribute key has been
found when processing: Table: 'dbo_Orders', Column: 'Project', Value:
'client service stuff'. The attribute is 'Project'.
'Project' is an attribute of the 'Orders' dimension, but not a key. Nowhere did I indicate that the Project column is a key! I should be able to have as many duplicates as necessary, just like a first name field.
I'm new at Analysis Services project and really need to get past the fact that SSAS is constantly complaining about duplicate values when it should be perfectly OK to have duplicate values. I'm sure this must be something simple that I'm overlooking.
Edit: I realize that it is possible to set KeyDuplicate = ReportAndContinue/ReportAndStop
and it is also possible to set KeyColumns
and NameColumns
. But this multistep process seems very cumbersome for what would seem should be a very normal operation, like adding Address1, Address2, Address3, Firstname, Zipcode, and other fields that normally are duplicated. I can't believe this cumbersome process need to be applied to all such fields?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(16)
这通常是源表/视图中同时存在空白和 NULL 的结果。
本质上,SSAS 对每个属性都执行此操作
SELECT DISTINCT COALESCE(attr,'') FROM SOURCE
默认情况下,分析服务会将 NULL 转换为空白,从而导致生成的 Feed 中出现重复值空白 - 因此会出现错误。
我同意这很糟糕,并且对新玩家来说是一个很大的痛苦。
解决方案:从数据源中删除所有空值,例如在各处使用 ISNULL / COALESCE,或者使用 where 子句过滤掉包含空值的行,或者在处理多维数据集之前运行 update 语句将所有空值替换为值等。
This is usually a result of having both blanks and NULLs in the source table/view.
Essentially, SSAS does this for every attribute
SELECT DISTINCT COALESCE(attr,'') FROM SOURCE
Analysis services by default converts NULLs to blanks, resulting in duplicate value blanks in the resulting feed - hence the error.
I agree this sucks and is a major pain for new players.
Solution : Remove all nulls from the data source, for example by using ISNULL / COALESCE everywhere, or filtering out rows containing null using where clause, or running update statement to replace all nulls with values before processing the cube, etc.
我遇到了同样的问题,属性中没有空白或 NULL 值。
经过一番分析,我发现有些字符串末尾有换行符。因此,如果属性的 2 个值几乎相同,但其中一个在末尾有换行符,而另一个没有,则 SSAS 会引发“重复属性键”错误。
可以通过从属性中删除换行符来修复它。
我使用以下定义创建了计算列:
我在多维数据集中使用了此计算列,并且错误消失了。
I had the same issue, and there was no blank or NULL values in the attribute.
After some analysis, I found that some strings had line break character on the end. So, if 2 values of the attribute are nearly the same, but one of them has line break character at the end, and the other doesn't, then SSAS raises “Duplicate attribute key” error.
It can be fixed by removing line break character from the attribute.
I created calculated column with following definition:
I used this calculated column in the cube, and the error disappeared.
右键单击该属性并选择“属性”。找到位于“属性”窗口中“源”类别下的“KeyColumn”。编辑“KeyColumn”属性,它将显示一个用户友好的窗口。
删除窗口右侧(关键列)的属性,并将其替换为左侧(可用列)的实际 id 列。
然后编辑“NameColumn”属性,将出现相同的窗口。将属性列(要显示的实际数据)从左侧移动到右侧。
在 VS 2010 Shell SSDT 中测试。
Right click the attribute and select "Properties". Find "KeyColumn" which is located under the "Source" category within the Properties Window. Edit the "KeyColumn" property, it will display a user friendly window.
Remove the attribute from the right (Key Columns) side of the window and replace it with the actual id column from the left (Available Columns) side.
Then edit the "NameColumn" property, the same window will appear. Move the attribute column (the actual data you want to display) from the left side to the right.
Tested in VS 2010 Shell SSDT.
今天刚刚发生在我身上,我挠了挠头,因为这里的解决方案都不起作用。终于解决了它,并认为我会为其他人添加我的解决方案,以谷歌搜索此错误并像我一样到达这里。
就我而言,它不是 NULL 和空白字符串,因为我已将 [NullProcessing] 值设置为“UnknownMember”。相反,它是[修剪]值,在我的例子中它被设置为“右”。
虽然我知道我是如何解决的(?),但我并不是 100% 知道原因,但我假设当 SQL Server 这样做时,它是 SELECT DISTINCT(col) FROM source 并且 [Trimming] 值设置为这样,分析服务器稍后会从末尾删除制表符(例如 SQL Server 中的 RTRIM 则不会),并以重复项结束。
因此,将 [Trimming] 设置为“None”可能会解决这个问题,因为选项卡是我不需要的数据(我的数据是从外部源解析/读取/输入的),我只是替换了列中的选项卡,然后对立方体进行处理又好了。
Just had this happen to me today and scratched my head for a while as none of the solutions here worked. Finally solved it and thought I'd add my solution for anyone else googling this error and arriving here just as I did.
In my case it was not
NULL
and blank strings as I had the [NullProcessing] value already set to "UnknownMember". Rather it was the [Trimming] value, in my case it was set to "Right".While I know how I solved(?) it I am not 100% as to why, but I assume when SQL Server does it's
SELECT DISTINCT(col) FROM source
and the [Trimming] value is set as such, Analysis server later removes among other things tab chars from the end (whichRTRIM
in SQL Server for example does not) and ends up with duplicates.So setting [Trimming] to "None" might solve it, since the tabs was data I did not need (my data is parsed/read/entered from external sources) I simply replaced tabs in the column and after that processing of the cube is fine again.
虽然我在本页上的其他解决方案有效(并且根据情况可能更理想),但这是一个替代解决方案:
这是我的部分错误的模型:
我进行了快速搜索:
事实证明有两个与此匹配的 dim_attribute1.name 的不同条目:
第一个解决方案将它们毫无问题地拆分,因此它是一个可行的解决方案(加上性能奖励)。然而,另一种选择(如果想将文本值保留为键)是更改排序规则:
包括“区分大小写”。
其他类似的问题可能是空白字符和其他容易发现文本中细微变化的问题。
While my other solution on this page works (and depending on situations might be more ideal), this is an alternate solution:
Here is a mock up of part of my error:
I did a quick search for:
It turns out that there were two different entries for dim_attribute1.name which matched this:
The first solution split them without issue, so it is a working solution (plus the performance bonus). However an alternative (if one wants to keep the text values as keys) is to change the Collation:
To include 'case sensitive'.
Other similar issues can be white space characters and other easy to not spot subtle changes in the text.
我今天遇到了类似的问题(相同的错误消息),为了让其他人遇到同样的问题,我在我的维基上添加了一些注释: http://www.david-halliday.co.uk/wiki/doku.php?id=databases:oracle&#select_dates_for_ssas_include_hierarchy
我的案例是 SQL(经过简化和重新措辞以保护无辜者) ):
奇怪的是,在某些情况下,dim_attribute1_name 会发生错误,但不是 dim_attribute2_name。然而,在这个特殊情况下,属性是完全相同的。最后的解决方案是将 SQL 更改为:
然后在维度(隐藏列表中的 ID)中使用属性键的 id 值和属性名称的名称。我以前没见过这种情况,但由于某种原因它发生在这里。我相信这个解决方案比设置多维数据集来处理忽略重复的键错误更好。
我认为,如果构建一个维度连接表,这将提供更好的性能/可靠性。但不要引用我的话。
I had a similar issue today (same error message), for the sake of anyone else getting here with the same problem I put some notes on my wiki: http://www.david-halliday.co.uk/wiki/doku.php?id=databases:oracle&#select_dates_for_ssas_include_hierarchy
My case was SQL (simplified and reworded to defend the innocent):
The strange thing was the error was happening for some cases of dim_attribute1_name but not dim_attribute2_name. However this particular case the attribute was exactly the same. In the end the solution was to change the SQL to:
Then use in the dimension (hiding the IDs in the list) the id value for the key of the attribute and the name for the name of the attribute. I haven't seen this before but for some reason it happened here. This solution I believe is better than setting the cube to process ignoring duplicate key errors.
I presume that if one is building a dimension joining tables this will give better performance/reliability. But don't quote me on that.
我遇到了同样的问题,并且找到了解决方法。
右键单击“立方体”=> “进程”=> “更改设置”=> “维度关键错误”
活动“用户自定义错误配置”
为这四个下拉列表设置“忽略错误”
“找不到钥匙”
“重复的钥匙”
“空键转换为未知”
“不允许空键”
键的问题将被忽略。
I had the same problem and I found a workaround for it.
Right Click in "Cube" => "Process" => "Change Settings" => "Dimension Key Errors"
Active "User Custom Error Configuration"
Set "Ignore Errors" for this four drop down list
"Key Not Found"
"Duplicated Key"
"Null key converted to unknown"
"Null key not allowed"
The problem with keys will be ignored.
在我尝试将 ID 添加到属性的键列后,我遇到了问题。此后我删除了该键,但发现处理过程中的 select 语句仍然引用 ID,使得该属性不唯一。我找不到通过属性属性解决此问题的方法,因此我删除了整个维度并重新创建了它。这解决了这个问题。
I got the problem after I had been playing around with adding an ID into the key column of an attribute. I had since removed the key but found that the select statement during processing was still referring to the ID, making the attribute non unique. I couldn't find a way of resolving this via the attribute properties, so I deleted the whole Dimension and recreated it. This fixed the issue.
请阅读此博客:重复的属性键已找到...。查看原因 1 的详细解释。它将解释为什么会发生这种情况。
谢谢你们
内德
Please read this blog: a duplicate attribute key has been found.... Look at the long explanation for reason 1. It will explain why exactly this is happening.
Thanks guys
Ned
以上都没有为我解决。有效的方法与埃里克·W. (Eric W.) 的建议类似。
我必须为我的属性设置多个关键列。例如,属性“城市”需要键列“国家”、“州”和“城市”。
更多信息请参见:https://www.mssqltips.com/sqlservertip/3271/sql-server-analysis-server-ssas-keycolumn-vs-namecolumn-vs-valuecolumn/
None of the above solved for me. What worked was something similar to what Eric W. suggested.
I had to set up multiple Key Columns for my attributes. For example, the attribute "City" needs the Key Columns "Country", "State", and "City".
More info here: https://www.mssqltips.com/sqlservertip/3271/sql-server-analysis-server-ssas-keycolumn-vs-namecolumn-vs-valuecolumn/
如果它对像我这样的其他准新手有帮助,我将概述一个解决方案,这是我在尝试部署跨越多年的日期维度时与“重复属性键”错误消息作斗争后最终找到的解决方案。例如,错误消息表明我的 CalendarQuarter 属性中有重复的属性键。最初这让我很困惑,因为每一整年都有四个季度(即 1、2、3 和 4),所以我当然有重复的。我终于意识到这就是问题所在——换句话说(与该线程的标题相反)属性是关键。我通过在 DSV 的日期表中添加一个名为“CalendarQuarterKey”的计算列来解决这个问题,以生成 CalendarQuarter 属性的唯一键,例如,“20171”而不是 2017 年第一季度的“1”,“20172”而不是仅“2” 2017 年第二季度等。与我的 CalendarMonth 属性同上:每个完整的年份有十二个月(即 1, 2, 3...,11, 12)所以当然我那里也有重复的。相同的解决方案:我在 DSV 的日期表中添加了一个名为“CalendarMonthKey”的计算列,以生成 CalendarMonth 属性的唯一键,例如 2017 年 1 月的“201701”而不是“1”,2017 年 1 月的“201702”而不是“2” 2017 年 2 月等。然后,我使用了我的新“CalendarQuarterKey”和“CalendarQuarterKey”。 “CalendarMonthKey”列分别作为我的 CalendarQuarter 和 CalendarMonth 属性的 KeyColumn。这可能不是首选的解决方案,但它对我有用,我终于可以重新开始构建我的立方体了。
In case it helps other quasi-newbies like me, I’ll outline a solution that I finally figured out after struggling with the “duplicate attribute key” error message while trying to deploy a Date dimension spanning multiple years. The error message indicated, for example, that I had duplicate attribute keys in my CalendarQuarter attribute. That initially confused me because every complete year has four quarters (i.e. 1, 2, 3 & 4) so of course I had duplicates. It finally dawned on me that that was the problem--in other words (and contrary to the title of this thread) the attribute WAS the key. I solved it by adding a “CalendarQuarterKey” named calculation column to my DSV’s Date table to yield unique keys for my CalendarQuarter attribute, e.g. “20171” instead of just “1” for 2017 Q1, “20172” instead of just “2” for 2017 Q2, etc. Ditto with my CalendarMonth attribute: every complete year has twelve months (i.e. 1, 2, 3...,11, 12) so of course I had duplicates there as well. Same solution: I added a “CalendarMonthKey” named calculation column to my DSV’s Date table to yield unique keys for the CalendarMonth attribute, e.g. “201701” instead of just “1” for January 2017, “201702” instead of just “2” for February 2017, etc. Then, I used my new “CalendarQuarterKey” & “CalendarMonthKey” columns as the KeyColumn for my CalendarQuarter and CalendarMonth attributes respectively. This may not be the preferred solution, but it worked for me and I can finally get back to building my cube.
我通过在我对关系数据库的视图上指定排序规则来解决,如下所示。
COALESCE([Transação 描述],'') COLLATE Latin1_General_CI_AI
I solved by specifying the COLLATION on my views on the relational database as follow.
COALESCE([Descrição da Transação],'') COLLATE Latin1_General_CI_AI
如果您的数据同时包含 NULL 和 '',SSAS 会给出重复的属性键,因为它认为 NULL 是 ''。您不必触摸您的数据即可解决此问题。您可以转到数据源视图并使用表达式 COALESCE(mycolumn, '') 添加命名计算,然后在维度中使用该计算而不是原始列。这将解决数据源视图级别的问题,并且维度将处理得很好。
If your data contains both NULLs and '' SSAS give out duplicate attribute key, because it considers NULLs to be ''. You don't have to touch your data to fix this. You can go to your data source view and add a named calculation with expression COALESCE(mycolumn, ''), then use that in your dimension instead of the original column. This will fix the problem at the data source view level and the dimension will process fine.
如果您仍然想继续部署和部署,请给您一个解决方法。多维数据集浏览。
在“处理多维数据集”窗口下,将维度键错误设置更改为自定义。
您将能够无缝部署和部署浏览立方体。
这里的权衡是您可能无法获得预期的结果。
Lemme give you a workaround if you still want to go ahead with deployment & cube browsing .
Under 'process cube' window, change dimension key error settings to custom .
You would be able to seamlessly deploy & browse the cube .
trade-off here is that you might not get the results which you expected.
有时需要在 keyColumns 中组合键来解决重复的属性键
some time that need composite key in keyColumns to resolve the duplicate attribute key
由于各种原因,我多次遇到此错误,但最近遇到了一个相当模糊的原因:文本列中存在 beta ß 字符。尽管该列中的数千个独特单词使用了世界上每一个晦涩的 ASCII 代码的大杂烩,但 SSAS 仅在处理包含 ß 符号的列值时才会出现阻塞。空值、重复、修剪等都被系统地排除了。这很可能与 MSDN 线程 SSAS 2012 存在“ss”和“ß”重复键错误,其中 SSAS 出于某种难以理解的原因将 ß 值解释为“ss”,即使排序规则设置正确。就我而言,将 SSAS 列属性中的排序规则设置为与关系端 SQL_Latin1_General_CP1_CS_AS 源列的排序规则相匹配并不能解决此问题;我还必须更改整个服务器的排序规则。在其他列依赖于不同排序规则的某些环境中,此解决方法可能会很痛苦,但在我的情况下,它回避了这个问题,并允许我顺利处理维度。我希望这可以帮助下一个人遇到同样的“陷阱”。
I've run into this error many times for various reasons, but recently encountered a rather obscure cause: the presence of the beta ß character in a text column. Despite the fact that the thousands of unique words in the column used a hodgepodge of every obscure ASCII code under the sun, SSAS choked only while processing column values that included the ß symbol. Nulls, duplicates, trimming and the like were all systematically ruled out. This is in all likelihood related to unfathomable and unsolved issue discussed in the MSDN thread SSAS 2012 duplicate key error with 'ss' and 'ß', in which SSAS interpreted ß values as 'ss' for some inscrutable reason, even when the collation settings were correct. In my case, setting the Collation in the SSAS column properties to match the source column's collation of SQL_Latin1_General_CP1_CS_AS on the relational side did not fix this; I had to also change the collation for the entire server. This workaround might be painful in certain environments where other columns depend on different collations, but it skirted this issue in my case and allowed me to process the dimension without a hitch. I hope this helps the next person to stumble over the same "gotcha."