Forum Discussion

abc_777's avatar
abc_777
Solution Specialist
2 years ago
Solved

hi

Hi,

 

I have following sample where i have created_at, status and order_code

for few order I have Confirmed, Delivered, On Process,Shipped on same day

but for few order when get after 8:00:00 PM then deliver that to next day after 8:00:00 AM (so no Confirmed, On Process, Shipped till next day)

 

I want to find Order time and average order time

     from order Order Placed to On Confirmed ,

     from order Confirmed to On process,

     from On process to Shipped,

     from Shipped to Delivered,

 

so

1) i need to seperate calculation orders that are placed after 8:00:00 PM and before 8:00:00 AM (this time will affect to my average calculation)

 

order_codestatuscreated_at
231101101451663Order placed01-11-23 08:16:00 PM
231101101451663Confirmed02-11-23 10:35:00 AM
231101101451663Delivered02-11-23 11:36:00 AM
231101101451663On Process02-11-23 10:36:00 AM
231101101451663Shipped02-11-23 10:40:00 AM
   
231101102553553Order placed04-11-23 08:01:00 PM
231101102553553Confirmed05-11-23 10:29:00 AM
231101102553553Delivered05-11-23 11:26:00 AM
231101102553553On Process05-11-23 10:30:00 AM
231101102553553Shipped05-11-23 10:32:00 AM


2) I want to find same day time difference of Confirmed and shipped as per order_code from 8:00:00 AM to 8:00:00 PM

 

order_codestatuscreated_at
231101101451773Confirmed01-11-23 10:16:00 AM
231101101451773Delivered01-11-23 13:06:00 AM
231101101451773On Process01-11-23 10:36:00 AM
231101101451773Shipped01-11-23 10:37:00 AM
   
231101102553846Confirmed02-11-23 10:29:00 AM
231101102553846Delivered02-11-23 13:26:00 AM
231101102553846On Process02-11-23 10:30:00 AM
231101102553846Shipped02-11-23 10:30:00 AM

 

please help me out for these calculations

 

thanks

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi abc_777 

    It is a new requirement, You can start a new post on the forum, and if my solution is helpful to you, please consider marking it as a solution.

     

    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.

9 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi abc_777 

    You can create a measure

    Measure =
    VAR _ADD =
        ADDCOLUMNS (
            FILTER (
                ALLSELECTED ( 'Table' ),
                [order_code] IN VALUES ( 'Table'[order_code] )
            ),
            "Flag",
                VAR A =
                    VALUE ( FORMAT ( [created_at], "YYYYMMDD" ) & "0800" )
                VAR B =
                    VALUE ( FORMAT ( [created_at], "YYYYMMDD" ) & "2000" )
                VAR C =
                    VALUE ( FORMAT ( [created_at], "YYYYMMDDHHMM" ) )
                RETURN
                    IF ( C >= A && C <= B, 1 )
        )
    VAR _filter =
        MAXX ( FILTER ( _ADD, [status] IN VALUES ( 'Table'[status] ) ), [Flag] )
    RETURN
        IF (
            _filter = 1,
            DATEDIFF (
                MINX ( FILTER ( _ADD, [Flag] <> 0 ), [created_at] ),
                MAXX ( FILTER ( _ADD, [Flag] <> 0 ), [created_at] ),
                MINUTE
            )
                / SUMX ( _ADD, [Flag] )
        )
    

    Output

     

    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.

    • abc_777's avatar
      abc_777
      Solution Specialist

      Hello Anonymous 

       

      thanks for your reply and try but i want the time difference of each status  and want to exclude 8:00:00 PM to 8:00:00 AM

       

      I want to find time difference of Order time and average order time

           from order Order Placed to On Confirmed ,

           from order Confirmed to On process,

           from On process to Shipped,

           from Shipped to Delivered,

       

      I hope you can help me out

       

      thanks

       

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi abc_777 

        I am confused that, based on your original information, you can to calculate  time difference of Confirmed and shipped as per order_code from 8:00:00 AM to 8:00:00 PM and now you want to calculate time difference for each status, what actual output you want?

         

        Best Regards!

        Yolo Zhu