如何计算表格中一栏的总数 [英] How to calculate the total of a column in a table

查看:142
本文介绍了如何计算表格中一栏的总数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在下面的表格中,我将度量 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]))

这篇关于如何计算表格中一栏的总数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆