Forum Discussion

Nicky_The_Knows's avatar
Nicky_The_Knows
Frequent Visitor
2 years ago

Elapsed Time Between Two Dates With Different Rows showing muliplte key values

Good morning,

 

I need to calculate the elapsed time between two dates that is found on two separate rows. Each row has an ID column that will tie the two rows together as well as task names that will be used to find the start and stop time.

 

Each order number will appear twice, once for each wire task that is being completed. I need to find the elapsed time, excluding weekends, from the start of the initial wire task (task requested date) to the completion of the wire approval task (task received date

 

 

 

I researched what I could and based on what I found, this seemed like the best approach but still getting an error.

 

Outgoing Wire Elased Time =

VAR StartTask = CALCULATE(SELECTEDVALUE('hsoa cvw_DashboardSSCTasks_HSOA'[OrderNumber]),'hsoa cvw_DashboardSSCTasks_HSOA'[TaskName] = "HSoA Outgoing Wire")
VAR StopTask = CALCULATE(SELECTEDVALUE('hsoa cvw_DashboardSSCTasks_HSOA'[OrderNumber]),'hsoa cvw_DashboardSSCTasks_HSOA'[TaskName] = "HSoA Outgoing Wire Approval")
VAR StartDate = CALCULATE(SELECTEDVALUE('hsoa cvw_DashboardSSCTasks_HSOA'[TaskRequestedDate]),'hsoa cvw_DashboardSSCTasks_HSOA'[TaskName] = "HSoA Outgoing Wire")
VAR EndDate = CALCULATE(SELECTEDVALUE('hsoa cvw_DashboardSSCTasks_HSOA'[TaskReceivedDate]),'hsoa cvw_DashboardSSCTasks_HSOA'[TaskName] = "HSoA Outgoing Wire Approval")

VAR Results = CALCULATE(
                DATEDIFF(StartDate,EndDate,DAY),
                StartTask = StopTask)
   
RETURN
    Results

 

5 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Nicky_The_Knows 

    You can refer to the following measure

    Outgoing Wire Elased Time =
    VAR _requ =
        MINX (
            FILTER (
                ALLSELECTED ( 'hsoa cvw_DashboardSSCTasks_HSOA' ),
                [OrderNumber] IN VALUES ( 'hsoa cvw_DashboardSSCTasks_HSOA'[OrderNumber] )
            ),
            [TaskRequestedDate]
        )
    VAR _rece =
        MAXX (
            FILTER (
                ALLSELECTED ( 'hsoa cvw_DashboardSSCTasks_HSOA' ),
                [OrderNumber] IN VALUES ( 'hsoa cvw_DashboardSSCTasks_HSOA'[OrderNumber] )
            ),
            [TaskRequestedDate]
        )
    RETURN
        DATEDIFF ( _requ, _rece, SECOND )
    

     

    Best Regards!

    Yolo Zhu

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

    • Nicky_The_Knows's avatar
      Nicky_The_Knows
      Frequent Visitor

      Morning Yolo

       

      I tried the solution above but it showing the same value for all rows. It looks like it is grabbing the first start time of the first order number and the stop time of the last order number and then applying that to all orders in the model.

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Nicky_The_Knows 

        Can you provide some more sample data and the output you want?

         

        Best Regards!

        Yolo Zhu