Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. 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!
User | Count |
---|---|
84 | |
73 | |
67 | |
42 | |
35 |
User | Count |
---|---|
109 | |
56 | |
52 | |
45 | |
43 |