Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
78 | |
78 | |
59 | |
35 | |
33 |
User | Count |
---|---|
100 | |
62 | |
56 | |
47 | |
41 |