对 Power BI 中首次出现的不同值求和 [英] Sum distinct values for first occurance in Power BI
问题描述
在 Power BI 中,我的数据中有一些重复的条目,只有 1 列不同,这是一个详细信息"列.
In Power BI I have some duplicate entries in my data that only have 1 column that is different, this is a "details" column.
Name | Value | Details
Item 1 | 10 | Feature 1
Item 1 | 10 | Feature 2
Item 2 | 15 | Feature 1
Item 3 | 7 | Feature 1
Item 3 | 7 | Feature 2
Item 3 | 7 | Feature 3
我知道这是数据结构的问题,但无法更改.
I realize this is an issue with the data structure, but it cannot be changed.
基本上,当我总结 Power BI 卡上的值列时,我只希望它为每个唯一名称求和,所以在这种情况下:
Basically, when I sum up my Value column on a Power BI card, I only want it to sum for each unique name, so in this case:
Total = 10 + 15 + 7
我将使用矩阵中的详细信息,因此我不能简单地从查询编辑器中删除重复项.
I will be using the details in a matrix, so I cannot simply remove the duplicates from within the Query Editor.
有什么方法可以用 DAX 公式过滤吗?只是对第一次出现的项目求和?
Is there any way I can filter this with a DAX formula? Just summing the first occurrence of an item?
推荐答案
您可以按如下方式创建度量:
You can create a measure as follows:
Total = SUMX(DISTINCT(Data[Name]), FIRSTNONBLANK(Data[Value], 0))
它将为所有不同的 Name
返回第一个非空白 Value
并将其汇总.
It will return the first non-blank Value
for all distinct Name
and sum it up.
结果:
这篇关于对 Power BI 中首次出现的不同值求和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!