如何计算表格中一栏的总数

编程入门 行业动态 更新时间:2024-10-27 21:16:58
本文介绍了如何计算表格中一栏的总数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

更多推荐

如何计算表格中一栏的总数

本文发布于:2023-10-14 19:04:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1491933.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表格   总数

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!