Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
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%
Solved! Go to Solution.
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
@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
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
Thank you very much! I will use this logic in the future a ton.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 51 | |
| 37 | |
| 35 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 70 | |
| 64 | |
| 39 | |
| 33 | |
| 23 |