在下面的表格中,我将度量 Valor Total定为:
In my table below, I've got the measure "Valor Total" as:
Valor total = SUM('Códigos e valores'[Valor unitário])*SUM(Csv[Quant.])
这对表的所有行都有效,除了底部的总计之外,因为定义不能数量*价格。
This works ok for all the rows of the table except for the grand total at the bottom, because the definition can't be quantity * price.
这里的问题是字段 Quant位于与另一个表(Table2)具有多对一关系的表上。
The problem here is that the field "Quant" is on a table with many-to-one relationship with another table (Table2).
此表2与字段 ValorUnitário所在的Códigose valores表具有一对多关系。
This Table2 has a relationship of one-to-many to table "Códigos e valores" where field "Valor Unitário" is located.
因此,SUMX在这种情况下不起作用,即使表达式中没有RELATED也是如此。
Therefore, SUMX doesn't work in this scenario, not even with a RELATED in the expression.
但是如何以正确的方式表示呢?
But how to express this in the correct way?
推荐答案假设您的两个表通过某种 ID 列关联,您应该能够做这样的事情:
Assuming your two tables are related by some kind of ID column, you should be able to do something like this:
Valor total = SUMX( SUMMARIZE('Códigos e valores', 'Códigos e valores'[ID], "Quantity", SUM(Csv[Quant.]), "Value", SUM('Códigos e valores'[Valor unitário])), [Quantity] * [Value])
也许是更好的方法是使用 Csv 表来创建度量:
TotalValue = SUMX(Csv, Csv[Quant.] * RELATED('Códigos e valores'[Valor unitário]))更多推荐
如何计算表格中一栏的总数
发布评论