与具有多个字段的日期表的关系

时间:2019-06-25 01:16:09

标签: powerbi relationship dax

我需要将日期表与来自不同表的多个字段链接起来,这些字段也必须相互链接。

3个数据源:

  • 里程碑(具有项目ID-唯一值)
  • 报告-收益(按项目ID与里程碑链接-重复项)
  • 批准的节省(与重复的项目ID重复的项目ID链接在一起)

要链接到的日期表:

里程碑表(在“关闭日期”字段中) 批准的储蓄(按“批准日期”字段)

此外,“里程碑”表还具有另一个“日期”字段,稍后我也需要将其链接。但是,我不能将日期表与多个字段链接起来。

enter image description here

1 个答案:

答案 0 :(得分:0)

您不能从两个相关的来源对表中的列进行切片。关系被设计为懒惰的,因此当您从关系的“一个”方面中获取一个值时,关系的“许多”方面就会随之而来。

User removed May from our 'One' Date table on the column Month, so let's remove all May dates from our 'Many' Approved Savings table.

关系的另一种可接受的用法是将第二个关系引入到“批准的储蓄”表的同一“许多”列,但来自不同的“一个”表。 (在本例中为里程碑)

User removed May from our 'One' Date table on the column Month, so let's remove all May dates from our 'Many' Approved Savings table. User also chose Mile Stone 445 from the 'One' Milestones table, so let's remove everything but May 2nd from the Date Column on the 'Many' Approved Savings table.

或者

User removed June from our 'One' Date table on the column Month, so let's remove all June dates from our 'Many' Approved Savings table. User also chose Mile Stone 999 from the 'One' Milestones table, so let's remove everything but December 29th from the Date Column on the 'Many' Approved Savings table.

在第二种情况下,显然“批准的储蓄”表将被过滤为无行,但它仍然是有效的配置。毕竟,您告诉它进行这种过滤,所以它只是在做它的工作。

但是,在您的情况下,当PowerBI Engine解释您的关系时,您引入了“歧义”。

User removed June from our 'One' date table on the column Month, so let's remove all June dates from our 'Many' Approved Savings table AND our 'Many' Milestones table . User also chose Mile Stone 999 from the 'One' Milestones but it doesn't exist because of the Previous relationship.

或者

The 'One' date table attempts to filter both Milestones and Approved Savings. Date table is sliced to contain set X of dates. Milestones translates that set of X dates in to set of Y Milestones records. Now Approved Savings has Milestones attempting to filter with set Y and the Date table attempting to filter with set X. These are potentially conflicting sets of dates and PowerBI doesn't know which set is valid.

如果删除了“日期表”->“批准的储蓄”关系,则会看到两件事:

  • 您现在可以将日期表->里程碑关系设置为有效
  • 您仅能为日期表->批准的储蓄设置无效的关系(假设您已激活日期表->里程碑关系)

在任何情况下,仍然可以通过在度量中使用USERELATIONSHIP来触发不活动的关系。我会提醒您不要使用它,IMO的使用表明存在麻烦或潜在设计不良的数据模型。