我有一个基本的表格,如下所示:
DayNo. Customer AgentsInvolved CallID
0 AAA 1 1858
0 AAA 3 1859
2 AAA 1 1860
0 BBB 2 1862
0 CCC 1 1863
0 DDD 3 1864
9 DDD 1 1865
9 DDD 4 1866
我需要能够找到仅联系一次并且仅与1个代理进行过交谈的客户百分比。因此,在上面的示例中,在4个不同的客户中,只有客户CCC属于此类别(1个呼叫,1个AgentInvolved)
因此所需的结果将是:1/4或25%
如何创建Power BI度量来执行此计算?
答案 0 :(得分:3)
尝试此措施:
Desired Result =
VAR summarizetable =
SUMMARIZECOLUMNS (
'table'[Customer],
"Calls", COUNT ( 'table'[CallID] ),
"Agents", SUM ( 'table'[AgentsInvolved] ),
"Day", SUM ( 'table'[DayNo.] )
)
RETURN
COUNTROWS (
FILTER ( summarizetable, [Calls] = 1 && [Agents] = 1 && [Day] = 0 )
)
/ COUNTROWS ( summarizetable )
在VAR summarizetable
中动态创建的汇总表如下所示:
答案 1 :(得分:2)
这是另一种方法:
Measure =
SUMX(
VALUES(Table2[Customer]),
CALCULATE(
IF(
DISTINCTCOUNT(Table2[CallID]) = 1 &&
SUM(Table2[AgentsInvolved]) = 1,
1,
0
),
Table2[DayNo.] = 0
)
) /
DISTINCTCOUNT(Table2[Customer])
如果您还想排除分母中的0天行,则将最后一行替换为
CALCULATE(DISTINCTCOUNT(Table2[Customer]), Table2[DayNo.] = 0)
答案 2 :(得分:0)
Desired Result =
VAR summarizetable =
SUMMARIZECOLUMNS (
'table'[AgentsInvolved],
'table'[DayNo.],
'table'[Customer],
"Calls", COUNT ( 'table'[CallID] )
)
)
RETURN
COUNTROWS (
FILTER ( summarizetable, [Calls] = 1 && 'table'[AgentsInvolved] = 1 && 'table'[DayNo.] = 0 )
) / DISTINCTCOUNT ( 'table'[Customer])