Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
mark_carlisle
Advocate IV
Advocate IV

Calculate Contacts Per Hour / Sum Distinct values

 

I have the follow measure which give me a Contacts Per Hour (CPH) figure for an individual agent on an individual day however when expanding the criteria to multiple days or agents this calculation does not work.

 

CPH =
SUM ( NonVoiceByProduct[TotalInteractions] )
    / (
        (
            SUM ( NonVoiceByProduct[OnlineHours] )
                / (
                    COUNT ( NonVoiceByProduct[OnlineHours] )
                        / DISTINCTCOUNT ( NonVoiceByProduct[OnlineHours] )
                )
        )
    )

 

So for Agent One on the 05/11/2018 (UK Date Format). The calculation would be;

 

52 / ( 35 / ( 5 / 1 ) ) = 7.43

 

However expanding this across multiple days or agents does not work so obviously the maths is incorrect. I would like a measure to produce the correct Contacts Per Hour regardless of the criteria selected. The calculation I am trying to acheive is;

 

TotalInteractions / OnlineHours

 

Calculating the total OnlineHours is what I am finding difficult as the OnlineHours value is repeated for each source and skill. It is important that these are kept in any result as I would like to be able to slice by skill to get a CPH by Skill.

 

The values I would expect for the applied criteria (in italics) follow;

 

Date = 05/11/2018

Agents = All

TotalInteractions = 110

OnlineHours = 14 (Two agents working 7 hours each)

CPH = 7.85

 

Date = All

Agents = Agent One

TotalInteractions = 104

OnlineHours = 17

CPH = 6.11

 

Date = All

Agents = Agent Two

TotalInteractions = 114

OnlineHours = 14

CPH = 8.14

 

An example of the data follows;

 

DateAgentNameInteractionSourceSkillNameTotalInteractionsOnlineHoursAgentId
05/11/2018Agent OneWeb ChatSkill140798765432
05/11/2018Agent TwoWeb ChatSkill116712345678
05/11/2018Agent TwoEmailSkill117712345678
02/11/2018Agent TwoWeb ChatSkill114712345678
02/11/2018Agent TwoEmailSkill116712345678
05/11/2018Agent OneWeb ChatSkill22798765432
05/11/2018Agent OneWeb ChatSkill22798765432
05/11/2018Agent OneWeb ChatSkill22798765432
05/11/2018Agent TwoWeb ChatSkill22712345678
05/11/2018Agent TwoWeb ChatSkill26712345678
05/11/2018Agent TwoWeb ChatSkill27712345678
05/11/2018Agent TwoEmailSkill23712345678
02/11/2018Agent TwoWeb ChatSkill26712345678
02/11/2018Agent TwoEmailSkill24712345678
02/11/2018Agent TwoEmailSkill22712345678
02/11/2018Agent TwoEmailSkill23712345678
05/11/2018Agent OneWeb ChatSkill36798765432
05/11/2018Agent TwoEmailSkill33712345678
02/11/2018Agent TwoEmailSkill39712345678
05/11/2018Agent TwoWeb ChatSkill41712345678
02/11/2018Agent TwoWeb ChatSkill31712345678
05/11/2018Agent TwoEmailSkill21712345678
05/11/2018Agent TwoEmailSkill21712345678
05/11/2018Agent TwoEmailSkill21712345678
02/11/2018Agent TwoWeb ChatSkill21712345678
02/11/2018Agent OneEmailSkill211098765432
02/11/2018Agent OneWeb ChatSkill211098765432
02/11/2018Agent OneWeb ChatSkill221098765432
02/11/2018Agent OneWeb ChatSkill231098765432
02/11/2018Agent OneWeb ChatSkill231098765432
02/11/2018Agent OneWeb ChatSkill341098765432
02/11/2018Agent OneEmailSkill1161098765432
02/11/2018Agent OneWeb ChatSkill1221098765432
2 ACCEPTED SOLUTIONS
Greg_Deckler
Community Champion
Community Champion

I would suggest using an AVERAGEX over a SUMMARIZE. Since your values are repeated by skill it will be necessary to introduce an average, or possibly MAX or MIN.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

Greg_Deckler
Community Champion
Community Champion

I think what you want is:

 

CPH = 
VAR __interactions = SUM([TotalInteractions])
VAR __onlineHours = SUMX(SUMMARIZE('Table14',[Date],[AgentName],[InteractionSource],[SkillName],"__onlineHours",AVERAGE([OnlineHours])),[__onlineHours])
RETURN DIVIDE(__interactions,__onlineHours)

See page 8 of attached file.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
v-danhe-msft
Microsoft Employee
Microsoft Employee

Hi @mark_carlisle,

Could you please tell me if your problem has been solved? If it is, could you please mark the helpful replies as Answered?

 

Regards,

Daniel He 

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-danhe-msft
Microsoft Employee
Microsoft Employee

Hi @mark_carlisle,

Based on my test, you could refer to below measure:

Measure = SUM(Table1[TotalInteractions])/
(CALCULATE(MAX(Table1[OnlineHours]),ALLSELECTED('Table1'[AgentName]))+CALCULATE(MIN(Table1[OnlineHours]),ALLSELECTED('Table1'[Date])))

Result:

1.PNG

You could also download the pbix file to have a view.

 

Regards,

Daniel He

 

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Greg_Deckler
Community Champion
Community Champion

I think what you want is:

 

CPH = 
VAR __interactions = SUM([TotalInteractions])
VAR __onlineHours = SUMX(SUMMARIZE('Table14',[Date],[AgentName],[InteractionSource],[SkillName],"__onlineHours",AVERAGE([OnlineHours])),[__onlineHours])
RETURN DIVIDE(__interactions,__onlineHours)

See page 8 of attached file.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Greg_Deckler
Community Champion
Community Champion

I would suggest using an AVERAGEX over a SUMMARIZE. Since your values are repeated by skill it will be necessary to introduce an average, or possibly MAX or MIN.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors