Forum Discussion

FlowViz's avatar
FlowViz
Helper III
4 years ago

Help with query across tables

Hi Guys,

 

I have a Jira dataset structured like so (edit: table name - Cycle Time 2):

 

And I also have a date table:

 

I want to be able to count:

1) How many items are In Progress (i.e. not in a status of 'Done' (in the NewStatus column) on a given date

2) For each WorkItemID, the age (i.e how long since it first went 'In Progress') of it on a given date.

 

For example, on the 19th March - there are 4 items 'In Progress' - TP-5, TP-6, TP-7 and TP-9

TP-5, TP-6, TP-7 have an age of 2, TP-9 would have an age of 0

 

I'm really struggling with how it could be done - .PBIX is here - can anyone help?

10 Replies

  • Hi, FlowViz 

    Create the following measures:

     

    _selectedDate = 
    var _date=SELECTEDVALUE('Dates'[Date])
    return
    Date(
        year(_date),MONTH(_date),DAY(_date))
    _isIn = 
    var _selectedDate=[_selectedDate]
    var _currentStatus=SELECTEDVALUE('CycleTime (2)'[NewStatus])
    
    var _ChangeDate=SELECTEDVALUE('CycleTime (2)'[ChangedDate])
    var _dateStart=DATE(YEAR(_ChangeDate),MONTH(_ChangeDate),DAY(_ChangeDate))
    var _CompletedDate=SELECTEDVALUE('CycleTime (2)'[CompletedDate])
    var _dateEnd=DATE(YEAR(_CompletedDate),MONTH(_CompletedDate),DAY(_CompletedDate))
    
    var _if=
    IF(
        _currentStatus<>"Done"&&
        AND(_selectedDate>=_dateStart,_selectedDate<=_dateEnd),1,0
        
    )
    return _if
    _count = SUMX('CycleTime (2)',CALCULATE([_isIn]))
    _age = 
    IF([_isIn]=0,BLANK(),DATEDIFF(SELECTEDVALUE('CycleTime (2)'[ChangedDate]),[_selectedDate],DAY))

     

    Result:

    Please refer to the attachment below for details.

    Hope this helps.

     

     

    Best Regards,
    Community Support Team _ Zeon Zheng


    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • FlowViz's avatar
      FlowViz
      Helper III

      Thank you!

       

      One final question - if there have been no changes to items then there will be no updates to the history, however they will still be 'In Progress'. So if my current chart now looks like this:

      It should stay at the value of 3 for the 22/23/24/25 March.

      Is there anyway to do this?

      • v-angzheng-msft's avatar
        v-angzheng-msft
        Community Support

        Hi, FlowViz 

         

        Try to create another measure like this:

        _sum = SUMX(FILTER(ALLSELECTED('CycleTime (2)'),'CycleTime (2)'[ChangedDate]<=MAX('CycleTime (2)'[ChangedDate])),[_count])

        Result:

        Please refer to the attachment below for details.

        Hope this helps.

         

         

        Best Regards,
        Community Support Team _ Zeon Zheng


        If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • FlowViz's avatar
      FlowViz
      Helper III

      Oh yes sorry I should have said that shouldn't i (doh) 

       

      Cycle Time (2) is the table...

  • FlowViz there seems to be a disconnect between the file you shared and the screenshot, there is no old status and new status column. Can you please revisit your post and make sure pbix file has the relevant details. 

    • FlowViz's avatar
      FlowViz
      Helper III

      This should now be updated in the file, apologies again...

  • Hi, FlowViz 

    For example, on the 19th March - there are 4 items 'In Progress' - TP-5, TP-6, TP-7 and TP-9

    TP-5, TP-6, TP-7 have an age of 2, TP-9 would have an age of 0

    I can't seem to understand the example from your sample data properly.
    Can you explain in more detail how the above example works

     

     

    Best Regards,
    Community Support Team _ Zeon Zheng


    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • FlowViz's avatar
      FlowViz
      Helper III

      Sure thing:

       

      On 17th March, the In Progress count should be 3 (TP-5, TP-6, TP-7) all of which should have an age of 0 (as they all went 'InProgress' that date).

      On 18th March, the In Progress count should be 2 (TP-5, TP-6, - TP-7 is finished) both of which should have an age of 1 (as they all went 'InProgress' the date before).

      On 19th March, the In Progress count should be 3 (TP-5, TP-6, TP-9) with an age of 2 for both TP-5 and TP-6, and an age of 0 for TP-9 (as it went 'InProgress' that date).

      On 20th March, the In Progress count should be 1 (TP-9 - TP-5 and TP-6 are now finished) with an age of 1 (as it went 'InProgress' the date before).

       

      I'm trying to create these two charts:

  • Thank you.

    That's still not quite what I'm after, I have refreshed the data (and fixed some DQ issues) and re-uploaded here.

     

    In the Excel template (not my own) I use, I input the following data:

     

    And seeing these results (this is the end result I'm trying to get to):