Power BI Distinct Count Incorrect Total

ⅰ亾dé卋堺 提交于 2019-12-12 01:24:22

问题


I am trying to calculate Distinct Count of 'Cust' in Table A using DAX as

CALCULATE(DISTINCTCOUNT('TableA'[Cust]))

Where I'm getting the distinct count correctly but the Total is Incorrect.

Any suggestions on correcting the formula would be helpful. Thanks!!


回答1:


Let's say you have four customers "Alex","John","Mike","Joe" in three BT groups AUT,CT,MT.

AUT has "Alex","John","Mike"

CT has "John","Joe"

MT has "Alex","John","Mike","Joe"

Your table would be

BT   Count
----------
AUT  3
CT   2
MT   4

Now since you have only four total customers, I would expect your total to be 4, not 3 + 2 + 4 = 9. In the latter, you've double counted Alex, Joe, and Mike and triple counted John.

If you really do want your total to be the sum of the subtotals (though I don't see why you would want this in this case), you can do the following:

AddSubtotals = SUMX(VALUES('TableA'[BT]), CALCULATE(DISTINCTCOUNT('TableA'[CustomerName])))

This will give the weird 9 subtotal.



来源:https://stackoverflow.com/questions/54153766/power-bi-distinct-count-incorrect-total

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