I have been working on a Power BI report that's pulling data from Jira's database and displaying various information about the Jira issues. I'm struggling with one measure for "Time in Status" that is attempting to show the DATEDIFF between each status. The data looks like this:
| Issue_ID | Old_Status | New_Status | Status_Change_Date | Issue_Created_Date | Sequence |
=======================================================================================================
| JIRA-001 | To Do | In Progress | 06/05/2020 08:00 AM | 06/01/2020 04:00 PM | 1 |
-------------------------------------------------------------------------------------------------------
| JIRA-001 | In Progress | Testing | 06/07/2020 02:00 PM | 06/01/2020 04:00 PM | 2 |
-------------------------------------------------------------------------------------------------------
| JIRA-001 | Testing | Done | 06/10/2020 09:45 AM | 06/01/2020 04:00 PM | 3 |
-------------------------------------------------------------------------------------------------------
| JIRA-002 | To Do | In Progress | 06/03/2020 09:00 AM | 06/02/2020 11:30 AM | 1 |
-------------------------------------------------------------------------------------------------------
| JIRA-002 | In Progress | Testing | 06/03/2020 03:45 PM | 06/02/2020 11:30 AM | 2 |
I've been attempting to create a Measure that looks at the Sequence number and then calculates the date/time difference between the Status_Change_Date of the specific row and the Status_Change_Date from previous record in the sequence. If the Sequence number is "1" then it should calculate the date/time difference between the Issue_Created_Date and the Status_Change_Date.
Here are the (somewhat oversimplified) results that I'm trying to get:
| Issue_ID | Status | Time_in_Status |
===========================================================
| JIRA-001 | To Do | 3 Days, 8 Hours |
-----------------------------------------------------------
| JIRA-001 | In Progress | 2 Days, 6 Hours |
-----------------------------------------------------------
| JIRA-001 | Testing | 2 Days, 19 Hours, 15 Mins |
-----------------------------------------------------------
| JIRA-002 | To Do | 21 Hours , 30 Mins |
-----------------------------------------------------------
| JIRA-002 | In Progress | 6 Hours 45 Mins |
I would be fine with the Time_In_Status showing a number with a decimal place (2.25 Days for instance). The Measures I've attempted to create, however, don't see to work.
Time_in_Status = IF(x.[Sequence] = 1,
DATEDIFF(x.[Issue_Created_Date], x.[Status_Change_Date], DAYS),
[I don't know how to do determine the DATEDIFF from the previous row by [Sequence]])
I know the Measure is sloppy but I'm still pretty green with DAX and Power BI.
Anyone have any ideas of how I achieve the results I want with that data?
UPDATE: There is a second table that is not being used in the DATEDIFF measure, but is being used to pull other data into the report and it's being used to filter the report using Sliders. The two tables are connected by the Issue_ID and the Issue_ID is not distinct in either of the tables. Here is the second table:
| Issue_ID | Issue_Title | Product_Team | Epic_ID | Epic_Version | Sprint | Component |
=============================================================================================================
| JIRA-001 | Do a thing | Mobile | JIRA-101 | 1.1.31 | Sprint 1.1 | iOS |
-------------------------------------------------------------------------------------------------------------
| JIRA-001 | Do a thing | Mobile | JIRA-101 | 1.1.31 | Sprint 1.2 | iOS |
-------------------------------------------------------------------------------------------------------------
| JIRA-002 | Do another | Mobile | JIRA-101 | 1.1.33 | Sprint 1.1 | iOS |
-------------------------------------------------------------------------------------------------------------
| JIRA-003 | Yet another | Web | JIRA-102 | 1.1.40 | Sprint 1.1 | Python |
-------------------------------------------------------------------------------------------------------------
The Sliders/filters I'm using are all from the second table (y). Those filters are:
- Product_Team
- Epic_Version
- Sprint
- Component