问题描述
在执行以下 DAX 表达式时,出现错误“USERELATIONSHIP 函数只能使用两列引用参与关系”。 那你能帮我看看这个表达有什么问题吗?
Accuracy_Last_6_Month =
VAR ReferenceDate = MAX(Calender[Date])
VAR Last_6Month =
DATESINPERIOD(
Calendar_Last6Month[Date].[Date],ReferenceDate,-6,MONTH
)
VAR Result =
CALculaTE(
[Accuracy],REMOVEFILTERS(Calender[Date]),KEEPFILTERS(Last_6Month),USERELATIONSHIP(Calender[Date],Calendar_Last6Month[Date].[Date])
)
RETURN
Result
表之间以非激活形式创建的关系:
表中使用的列:
解决方法
您应该能够使用单个日历。你的第二个日历是多余的。
我会这样写:
Accuracy_Last_6_Month =
CALCULATE([Accuracy],FILTER(ALL(Calender),Calender[Date] > MAX(Calender[Date])-180 &&
Calender[Date] <= MAX(Calender[Date])))
,
我猜这个错误是因为您在 USERELATIONSHIP 中使用了 Calendar_Last6Month[Date].[Date]
,它实际上不是表列。尝试删除度量中所有位置的 .[Date]
后缀:
Accuracy_Last_6_Month =
VAR ReferenceDate = MAX ( Calender[Date] )
VAR Last_6Month =
DATESINPERIOD ( Calendar_Last6Month[Date],ReferenceDate,-6,MONTH )
VAR Result =
CALCULATE (
[Accuracy],REMOVEFILTERS ( Calender[Date] ),KEEPFILTERS ( Last_6Month ),USERELATIONSHIP ( Calender[Date],Calendar_Last6Month[Date] )
)
RETURN
Result
我通常完全避免使用 these Time Intelligence suffixes。