Excel 如何让度量值查找基于行和列上下文的值?
我需要聚合一些基于行和列上下文的乘法。我最好用伪代码来描述这一点Excel 如何让度量值查找基于行和列上下文的值?,excel,powerpivot,dax,ssas-tabular,Excel,Powerpivot,Dax,Ssas Tabular,我需要聚合一些基于行和列上下文的乘法。我最好用伪代码来描述这一点 For each cell in the Pivot table SUM Foreach ORU Percent= Look up the multiplier for that ORU associated with the Column SUMofValue = Add all of the Values associated with that
For each cell in the Pivot table
SUM
Foreach ORU
Percent= Look up the multiplier for that ORU associated with the Column
SUMofValue = Add all of the Values associated with that Column/Row combination
Multiply Percent * SUMofValue
在过去的几天里,我尝试了很多方法,看了很多例子,但我遗漏了一些东西
具体而言,不起作用的是:
CALCULATE(SUM(ORUBUMGR[Percent]), ORUMAP)*CALCULATE(SUM(Charges[Value]), ORUMAP)
因为您正在对所有百分比进行求和,而不是只与MGR(即列上下文)关联的百分比求和
一种方法是使用嵌套的SUMX。将此度量添加到ORUBUMGR:
ValuexPercent :=
SUMX (
ORUBUMGR,
[PERCENT]
* (
SUMX (
FILTER ( CHARGES, CHARGES[ORU] = ORUBUMGR[ORU] ),
[Value]
)
)
)
对于ORUBUMGR中的每一行,您将用百分比乘以。。。。
费用中每行的值之和,其中ORUBUMGR ORU与费用ORU相同。然后求和该乘积