我正在尝试计算“货件参考”中不同的“位置”。
我有以下公式,该公式可以为我提供装货参考的位置总数,而不是不重复的总数。
ShipLocationCount =
COUNTX (
FILTER (
CustomerProfitabilityReport_Full_D365,
EARLIER ( CustomerProfitabilityReport_Full_D365[SHIPMENT_REF] )
= CustomerProfitabilityReport_Full_D365[SHIPMENT_REF]
),
CustomerProfitabilityReport_Full_D365[DELIVERY_ADDRESS_CODE]
)
然后我要运行一个度量,并使用此计算列作为过滤器来说明ShipLocationCount > 1
的位置。
谢谢
答案 0 :(得分:1)
如何代替过滤器呢?
ShipLocationCount =
CALCULATE (
DISTINCTCOUNT ( CustomerProfitabilityReport_Full_D365[DELIVERY_ADDRESS_CODE] ),
FILTER (
CustomerProfitabilityReport_Full_D365,
CustomerProfitabilityReport_Full_D365[SHIPMENT_REF]
= MAX ( CustomerProfitabilityReport_Full_D365[SHIPMENT_REF] )
)
)
您还可以尝试以下操作:
ShipLocationCount =
COUNTROWS (
SUMMARIZE (
CustomerProfitabilityReport_Full_D365,
CustomerProfitabilityReport_Full_D365[SHIPMENT_REF],
CustomerProfitabilityReport_Full_D365[DELIVERY_ADDRESS_CODE]
)
)
SUMMARIZE
函数对所引用列的不同组合进行分组。
编辑:如果您打算将这些公式用作计算列而不是度量,则需要对其进行修改以考虑它们所处的行上下文。
ShipLocationCount =
CALCULATE (
DISTINCTCOUNT ( CustomerProfitabilityReport_Full_D365[DELIVERY_ADDRESS_CODE] ),
ALLEXCEPT(
CustomerProfitabilityReport_Full_D365,
CustomerProfitabilityReport_Full_D365[SHIPMENT_REF]
)
)
和
ShipLocationCount =
COUNTROWS (
SUMMARIZE (
FILTER (
CustomerProfitabilityReport_Full_D365,
CustomerProfitabilityReport_Full_D365[SHIPMENT_REF]
= EARLIER( CustomerProfitabilityReport_Full_D365[SHIPMENT_REF] )
),
CustomerProfitabilityReport_Full_D365[DELIVERY_ADDRESS_CODE]
)
)