I'm quite new to Power BI and I try to query Azure DevOps
data for a Board with historical data.
I have made an OData
feed that queries data and returns the data below (see table) and for each row where IsCurrent
= True, I want to calculate the "blocked time" into a new Column BlockedTime
for that WorkItemId
. So I need to traverse records for that WorkItemId
and do date calculation.
I am kind of stuck currently after much delving into CALCULATE, Filters and more.
I have specified three scenarios for the WorkItemId
1, 72 and 149.
I use the column Index as the number to reference lines in my calculations below.
My query returns the following:
WorkItemId Revision Index AnalyticsUpdatedDate IsCurrent TagNames BlockedTime
72 7 0 06/19/2020 11.41.04 True See calculation 1
72 6 1 06/19/2020 11.41.04 False Blocked
72 5 2 06/18/2020 10.41.23 False Blocked
72 4 3 06/17/2020 09.38.54 False
72 3 4 06/16/2020 14.22.21 False Blocked
72 2 5 06/15/2020 15.01.02 False
72 1 6 06/14/2020 07.21.16 False
1 6 7 07/07/2020 09:58:12 True Blocked See calculation 2
1 5 8 07/07/2020 09:58:12 False
1 4 9 07/06/2020 10:22:02 False Blocked
1 3 10 07/05/2020 12:34:31 False
1 2 11 07/04/2020 13:51:30 False Blocked
1 1 12 07/03/2020 08:23:41 False
149 1 13 07/02/2020 10:01:55 False Blocked See calculation 3
RULES
Variable CurrentDate
contains current DateTime
When TagNames
contains "Blocked" text for a given line it is considered blocked from the date/time in AnalyticsUpdatedDate
and the time should be calculated "backwards" by traversing down in the records (Revision number going down) and summarized until a line without "Blocked" in TagNames
is encountered
Calculation 1: Calculate BLOCKED TIME and put the result into BlockedTime(0)
(AnalyticsUpdatedDate(1) - AnalyticsUpdatedDate(2)) +
(AnalyticsUpdatedDate(2) - AnalyticsUpdatedDate(3)) +
(AnalyticsUpdatedDate(4) - AnalyticsUpdatedDate(5))
Calculation 2: Calculate BLOCKED TIME and put the result into BlockedTime(7)
(CurrentDate - AnalyticsUpdatedDate(7)) +
(AnalyticsUpdatedDate(9) - AnalyticsUpdatedDate(10)) +
(AnalyticsUpdatedDate(11) - AnalyticsUpdatedDate(12))
Calculation 3: Calculate BLOCKED TIME and put the result into BlockedTime(13)
(CurrentDate - AnalyticsUpdatedDate(13))
Anyone who has any ideas of how this could be solved best?