Power BI:计算列或度量
Power BI: Calculated column or Measure
我有以下数据:
Table: 价格Table
Price Applicable1 Applicable2 Percentage
--------------------------------------------
100 Yes Yes 0.10
200 Yes No 0.50
300 No Yes 0.30
500 Yes Yes 0.40
我想计算最后一列中的价格百分比并显示在 power bi 报告的 table/matrix 中。
场景:如果两列Applicable1 and Applicable2
都等于Yes
,则计算最后一列中价格的百分比。
我的尝试:我采用了 New Column
并添加了以下 DAX:
Commission = IF( PriceTable[Applicable1] = "Yes" &&
PriceTable[Applicable2] = "Yes",
PriceTable[Price] * PriceTable[Percentage], 0)
问题:
- Which one should I use
New Column
OR Measure
?
- If
Measure
, then how to calculate the same?
使用新列,因为您的计算不是动态的,而是按行计算,因此请使用 NewColumn。
即使它的速度是预先计算好的如果您使用动态它会在每次启动报告时计算该值,这会减慢您的报告加载速度
Rob Collie 在“When to Use Measures vs. Calc Columns”
上有一篇很棒的博客 post
Reza Rad 还有一个好处post:
Measure vs Calculated Column: The Mysterious Question? Not!
我最喜欢的take-away是:
If you want to put it on rows, columns, slicers, or report filters, it
MUST be a column
我有以下数据:
Table: 价格Table
Price Applicable1 Applicable2 Percentage
--------------------------------------------
100 Yes Yes 0.10
200 Yes No 0.50
300 No Yes 0.30
500 Yes Yes 0.40
我想计算最后一列中的价格百分比并显示在 power bi 报告的 table/matrix 中。
场景:如果两列Applicable1 and Applicable2
都等于Yes
,则计算最后一列中价格的百分比。
我的尝试:我采用了 New Column
并添加了以下 DAX:
Commission = IF( PriceTable[Applicable1] = "Yes" &&
PriceTable[Applicable2] = "Yes",
PriceTable[Price] * PriceTable[Percentage], 0)
问题:
- Which one should I use
New Column
ORMeasure
?- If
Measure
, then how to calculate the same?
使用新列,因为您的计算不是动态的,而是按行计算,因此请使用 NewColumn。 即使它的速度是预先计算好的如果您使用动态它会在每次启动报告时计算该值,这会减慢您的报告加载速度
Rob Collie 在“When to Use Measures vs. Calc Columns”
上有一篇很棒的博客 postReza Rad 还有一个好处post:
Measure vs Calculated Column: The Mysterious Question? Not!
我最喜欢的take-away是:
If you want to put it on rows, columns, slicers, or report filters, it MUST be a column