Sum distinct values for first occurance in Power BI

杀马特。学长 韩版系。学妹 提交于 2020-01-14 04:14:15

问题


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.

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.

Is there any way I can filter this with a DAX formula? Just summing the first occurrence of an item?


回答1:


You can create a measure as follows:

Total = SUMX(DISTINCT(Data[Name]), FIRSTNONBLANK(Data[Value], 0))

It will return the first non-blank Value for all distinct Name and sum it up.

Results:



来源:https://stackoverflow.com/questions/43547620/sum-distinct-values-for-first-occurance-in-power-bi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!