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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Spudder112
Helper I
Helper I

Trying to Calculate How Many Employees Worked on Multiple Customers in Given Time Period

I had asked a similar question, but decided to take a different route after re-working some data...

 

Table 1

Order ID

Order Date

Order Amount

Employee ID

Customer ID

 

I want to figure out how many Employee worked on a different customer idea on each date.

 

Example data:

 

Employee ID   Employee Name    Customer    Date

1212                Jon                         5133           1/1/2023

2455                Sam                       1344           1/2/2023

2455                Sara                       11111          1/2/2023

9559                Charles                  3553           1/1/2023

2455                Sam                       4949           1/1/2023

2455                Sam                       1344           1/1/2023

 

Finished product:

 

Date:                                                                   1/1/2023    1/2/2023

Employees working more than 1 customer        33%            0%

 

2 ACCEPTED SOLUTIONS

Thank you for the quick response @Greg_Deckler!

 

This is giving me 98% across the board for every week (which I would expect to see around 30%). Something I accidentally omitted in my example data was that customer numbers will often repeat, and I can only count each unique customer once, sorry for the confusion!

View solution in original post

@Spudder112 Well that certainly makes a difference but should be an easy fix. PBIX is attached with ammended data to demonstrate a duplicate.

Employees Working More Than 1 Customer Measure = 
    VAR __NumEmployees = COUNTROWS(DISTINCT('Table'[Employee ID]))
    VAR __Table = SUMMARIZE('Table',[Date],[Employee ID],"__Count",COUNTROWS(DISTINCT(SELECTCOLUMNS('Table',"__Customer",[Customer]))))
    VAR __Result = DIVIDE( COUNTROWS(FILTER(__Table, [__Count] > 1)), __NumEmployees) + 0
RETURN
    __Result

 



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
Greg_Deckler
Community Champion
Community Champion

@Spudder112 Your sample data won't give you the results you expect because you have duplicate ID's for Sam and Sara but if you correct that this will work:

Employees Working More Than 1 Customer Measure = 
    VAR __NumEmployees = COUNTROWS(DISTINCT('Table'[Employee ID]))
    VAR __Table = SUMMARIZE('Table',[Date],[Employee ID],"__Count",COUNTROWS('Table'))
    VAR __Result = DIVIDE( COUNTROWS(FILTER(__Table, [__Count] > 1)), __NumEmployees) + 0
RETURN
    __Result


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...

Thank you for the quick response @Greg_Deckler!

 

This is giving me 98% across the board for every week (which I would expect to see around 30%). Something I accidentally omitted in my example data was that customer numbers will often repeat, and I can only count each unique customer once, sorry for the confusion!

@Spudder112 Well that certainly makes a difference but should be an easy fix. PBIX is attached with ammended data to demonstrate a duplicate.

Employees Working More Than 1 Customer Measure = 
    VAR __NumEmployees = COUNTROWS(DISTINCT('Table'[Employee ID]))
    VAR __Table = SUMMARIZE('Table',[Date],[Employee ID],"__Count",COUNTROWS(DISTINCT(SELECTCOLUMNS('Table',"__Customer",[Customer]))))
    VAR __Result = DIVIDE( COUNTROWS(FILTER(__Table, [__Count] > 1)), __NumEmployees) + 0
RETURN
    __Result

 



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...

Thank you very much! I will use this logic in the future a ton.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.