powerbi - 如何在 Power BI 中使用 DAX 中的筛选器计算百分比?
问题描述
我有两列
CustomerCode | Segmentation
AU656 | abc
AU765 | cdf
AU563 | abc
AU235 | abc
AU324 | opr
AU908 | opr
AU123 | pqr
AU234 |pqr
我必须找到一个不同的 CustomerCode 计数,其中分段是“abc”、“cdf”和“pqr”,并将其除以 CustomerCodes 的总数(全部)。
我创建了一个度量 -
#RSP =
CALCULATE (
DISTINCTCOUNT ( 'Table'[CustomerCode] ),
FILTER ( ALL ( 'Table' ), 'Table'[Segmentation] = "abc" ),
'Table'[Segmentation] = "cdf",
'Table'[Segmentation] = "opr"
)
但是,这没有任何价值。我是否使用错误的过滤器?我该如何计算?
解决方案
您的度量失败,因为分段不能同时是多个值。试试这个:
#RSP =
CALCULATE (
DISTINCTCOUNT ( 'Table'[CustomerCode] ),
'Table'[Segmentation] IN { "abc", "cdf", "opr" }
)
Ratio = DIVIDE ( [#RSP], DISTINCTCOUNT ( 'Table'[CustomerCode] ) )
推荐阅读
- android-studio - Android 应用开发 - 库 android-graphview
- python - 在 spyder 中使用烧瓶卡在本地服务器中
- r - 使用 R 和 httr 获取页面内容时出错:http://www2.bmf.com.br/pages/portal/bmfbovespa/lumis/lum-tipo-de-participante-ptBR.asp
- ios - 在 Swift 4 中从 String 对象创建 CFData 对象
- jquery - 用于为多个元素设置高度的 jQuery 循环
- c# - 如何隐藏打开chrome之前出现的Selenium黑色控制台窗口
- python - param-grid 将参数传递给底层函数。迷失在 kw_args
- python-3.x - 是否可以在 spaCy 中排除某些 POS 标签?Python
- segmentation-fault - 分段故障运动检测 Opencv4tegra
- json - 在构建和部署 SyntaxError 后反应 firebase 错误:预期的表达式,得到 '<'