3
votes

I have a basic table that looks like this:

 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

I need to be able to find the % of customers who only contacted only once, and spoke to 1 agent only. So from the above example, out of 4 distinct customers only customer CCC falls into this category (1 call, 1 AgentInvolved)

So the Desired result would be: 1/4 or 25%

How can I create a Power BI measure to do this calc?

3

3 Answers

3
votes

Try this measure:

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 )

The summarized table created on the fly in VAR summarizetable looks like this:

enter image description here

2
votes

Here's another approach:

Measure = 
SUMX(
    VALUES(Table2[Customer]),
    CALCULATE(
        IF(
            DISTINCTCOUNT(Table2[CallID]) = 1 &&
              SUM(Table2[AgentsInvolved]) = 1,
            1,
            0
        ),
    Table2[DayNo.] = 0
    )
) /
DISTINCTCOUNT(Table2[Customer])

If you want to exclude the 0 day rows in the denominator as well, replace the last line with

CALCULATE(DISTINCTCOUNT(Table2[Customer]), Table2[DayNo.] = 0)
0
votes
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])