Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I would like to know the average time it takes for Jobs to change from Worker X to any other worker. Timestamp is here shown as an integer. The result should be (2+10)/2 = 6. See that JobID 3 hasn't changed from Worker X and should be ignored in the calculation.
JobID | Timestamp | Worker |
2 | 15 | C |
3 | 12 | X |
1 | 8 | A |
1 | 4 | B |
1 | 3 | C |
2 | 5 | X |
1 | 2 | B |
2 | 1 | A |
1 | 0 | X |
Using this example, the logic behind the calculation is as follows:
Solved! Go to Solution.
Please try this measure expression. It returns 6 for your example data. If you want a more general solution, you can replace the FILTER(__summary, Jobs[Worker] = "X") with just __summary (to use it in a table for example to see the avg time for each employee.
Avg Job Change Time =
VAR __summary =
ADDCOLUMNS (
SUMMARIZE ( Jobs, Jobs[Worker], Jobs[JobID], Jobs[Timestamp] ),
"@nexttimestamp", CALCULATE (
MIN ( Jobs[Timestamp] ),
ALL ( Jobs ),
Jobs[Timestamp] > EARLIER ( Jobs[Timestamp] ),
Jobs[JobID] = EARLIER ( Jobs[JobID] )
) + 0
)
RETURN
AVERAGEX (
FILTER ( FILTER ( __summary, Jobs[Worker] = "X" ), [@nexttimestamp] > 0 ),
[@nexttimestamp] - Jobs[Timestamp]
)
If this works for you, please mark it as the solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Please try this measure expression. It returns 6 for your example data. If you want a more general solution, you can replace the FILTER(__summary, Jobs[Worker] = "X") with just __summary (to use it in a table for example to see the avg time for each employee.
Avg Job Change Time =
VAR __summary =
ADDCOLUMNS (
SUMMARIZE ( Jobs, Jobs[Worker], Jobs[JobID], Jobs[Timestamp] ),
"@nexttimestamp", CALCULATE (
MIN ( Jobs[Timestamp] ),
ALL ( Jobs ),
Jobs[Timestamp] > EARLIER ( Jobs[Timestamp] ),
Jobs[JobID] = EARLIER ( Jobs[JobID] )
) + 0
)
RETURN
AVERAGEX (
FILTER ( FILTER ( __summary, Jobs[Worker] = "X" ), [@nexttimestamp] > 0 ),
[@nexttimestamp] - Jobs[Timestamp]
)
If this works for you, please mark it as the solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
could you please provide detailed logic on the calculation? how to get 10 and 2 in your formula?
Proud to be a Super User!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
106 | |
94 | |
77 | |
65 | |
53 |
User | Count |
---|---|
145 | |
105 | |
104 | |
90 | |
63 |