Power Bi 中的循环依赖 [英] A circular dependency in Power Bi
问题描述
我计算了一个可以带来 2018 年自行车总销量的字段 - 一切正常将相同的公式复制到另一列以计算相同的 2017 年带来了此参考错误 - 如果我想使用具有不同参数的相同公式显示几列,我该如何移动它
I calculated a field that brings the total sales for bikes in 2018-all work fine copy the same formula to another column to calculate the same for 2017 brought this reference error -how can I move around it if I want to show a few columns using the same formula with different parameters
Sales_Bike_2018 =
CALCULATE (
[Total_Sales],
TrainingSample2[Business Segment] = "Bikes",
TrainingSample2[Year] = 2018
)
Sales_Bike_2017 =
CALCULATE (
[Total_Sales],
TrainingSample2[Business Segment] = "Bikes",
TrainingSample2[Year] = 2017
)
推荐答案
问题是您在没有唯一键的表上创建 2 列.
The problem is that you are creating 2 columns on a table that doesn't have a Unique Key.
当您创建 Sales_Bike_2018 时一切正常,因为它取决于表的其余列,但是当您创建列 Sales_Bike_2017 时,Sales_Bike_2017 的代码取决于其余列以及 Sales_Bike_2018.
When you create Sales_Bike_2018 everything works fine because it depends on the rest of the columns of your table but when you create the column Sales_Bike_2017, the code of Sales_Bike_2017 depends on rest of the columns as well as on Sales_Bike_2018.
类似的,如果可以创建 Sales_Bike_2017,那么 Sales_Bike_2018 将依赖于 Sales_Bike_2017,这是不允许的,这就是您收到循环依赖错误的原因.
Similary if it was possible to create Sales_Bike_2017 then Sales_Bike_2018 would have depended upon Sales_Bike_2017 and that's not allowed and that's why you get a circular dependency error.
解决办法:使用 REMOVEFILTERS () 删除由于上下文转换而来自两个新列的过滤器
Solution: Remove filters coming from both new columns due to context transition by using REMOVEFILTERS ()
Sales_Bike_2018 =
CALCULATE (
[Total_Sales],
TrainingSample2[Business Segment] = "Bikes",
TrainingSample2[Year] = 2018,
REMOVEFILTERS ( TrainingSample2[Sales_Bike_2017] )
)
Sales_Bike_2017 =
CALCULATE (
[Total_Sales],
TrainingSample2[Business Segment] = "Bikes",
TrainingSample2[Year] = 2017,
REMOVEFILTERS ( TrainingSample2[Sales_Bike_2018] )
)
这篇关于Power Bi 中的循环依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!