Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
aboliverABC
Frequent Visitor

Creating Ranking & Turn Around Time for complex Data

I am trying to calculate Turn-Around-Time from the time a customer registers, to the 1st time the order is completed & shipped. However, there are a few factors that need to be considered: 

 

  1. The Customer may have more than 1 Registration.
  2. A customer's Registration may have more than 1 order (unfortunately, there is no key to connect the orders to the registrations).
  3. The data set I am using is for a specific time frame.  So some customers may have orders from previous registrations in the data set, but I do not care about those orders. 
  4. I only need the Turn-Around-Time for the 1st Completed Order following a Completed Registration. There is an ‘Order Type’ in my data set that distinguish between Initial Fills & Refills, however it is not consistently marked.

 

I originally had a Registration Table & an Order Table.  I organized a Combined_Table (see below) based on Customer ID & "Trigger Date".  There is a step in the Registration process that "triggers" an Order to be auto generated.  Resulting in the Order Create Date often times being before the Registration date by a few minutes.  In other words, the Trigger Date is when the Order is Created, and may or may not correspond to the Registration's Auto Generated task.  

My thought process is to create a sequence column that will help me identify the correct Registration Date to use in my Turn-Around-Time calculation.  However, I can’t even get that right. I currently am using a calculated column to Identify the Sequence defined as:

  

Sequence =

    RANKX(

        filter(Combined_Table,

            (Combined_Table[Customer_Id]=earlier(Combined_Table[Customer_Id])&& Combined_Table [Order_num] <> blank())),

        Combined_Table [Order_Created_Date],

        ,

        asc,

        Dense)

 

Can someone help me correctly update my Sequence formula, as shown in the example below?

Can someone help me correctly calculate the TAT, as shown in the examples below?

 

Customer IDRegistration #Registration DateRegistration StatusTrigger_DateOrder #Order Created DateOrder StatusOrder TypeSequenceSequence UpdatedOrder Ship DateTAT
22528192   09/06/2022 17:362946303209/06/2022 17:36CompletedRefill1 09/06/2022 17:42 
225281923043442610/14/2022 21:28Completed10/14/2022 21:26    1   
22528192   10/18/2022 17:053054046210/18/2022 17:05CancelledInitial Fill21  
22528192   10/18/2022 17:103054074310/18/2022 17:10CompletedInitial Fill3210/18/2022 17:18= 10/18/22 17:18 - 10/14/22 21:28
225281923054121410/19/2022 15:29Completed10/19/2022 15:253056597410/19/2022 15:25CancelledInitial Fill41  
22528192   10/20/2022 15:213059404110/20/2022 15:21CompletedRefill5210/20/2022 15:22= 10/20/22 15:22 - 10/19/22 15:29
22528192   10/28/2022 16:323076311910/28/2022 16:32CancelledReshipment6310/28/2022 16:37 
231795292949723309/07/2022 18:36Completed09/07/2022 18:342949741609/07/2022 18:34CancelledInitial Fill11  
23179529   09/14/2022 22:142967004509/14/2022 22:14CancelledInitial Fill2209/14/2022 22:15 
231795292967386009/15/2022 12:08Completed09/15/2022 12:072967388509/15/2022 12:07CompletedInitial Fill3109/15/2022 12:10= 09/15/22 12:10 -09/15/22 12:08
23179529   10/10/2022 19:243026279010/10/2022 19:24CompletedRefill4210/10/2022 19:24 
25092056   08/23/2022 20:022918729008/23/2022 20:02CompletedRefill1 08/23/2022 20:04 
25092056   09/21/2022 20:432982270309/21/2022 20:43CompletedRefill2 09/21/2022 20:43 
25092056   10/24/2022 16:243065164510/24/2022 16:24CompletedInitial Fill3 10/24/2022 16:26 
250920563079907010/31/2022 21:28Completed10/31/2022 20:543079919910/31/2022 20:54CancelledInitial Fill41  
250920563080101310/31/2022 22:02Completed10/31/2022 21:553080109910/31/2022 21:55CancelledInitial Fill51  
25092056   11/21/2022 16:403262090311/21/2022 16:40CompletedRefill6211/21/2022 16:44= 11/21/22 16:44 - 10/31/22 22:02
35224529   08/23/2022 18:152918078508/23/2022 18:15CompletedInitial Fill1 08/23/2022 18:23 
352245292914053508/23/2022 18:18Completed08/23/2022 18:162918083808/23/2022 18:16CancelledInitial Fill21  
352245292969297309/15/2022 19:30Completed09/15/2022 19:292969308709/15/2022 19:29CancelledRefill3109/15/2022 19:40 
35224529   09/19/2022 19:352975660009/19/2022 19:35CompletedInitial Fill4209/19/2022 19:41= 9/19/22 19:41 - 9/15/22 19:30
352640382925076808/25/2022 19:11Completed08/25/2022 19:102925203608/25/2022 19:10CancelledInitial Fill11  
352640382932519508/30/2022 13:59Completed08/30/2022 13:582932527008/30/2022 13:58CancelledInitial Fill21  
35264038   08/30/2022 14:252932650708/30/2022 14:25CompletedInitial Fill3208/30/2022 14:27= 8/30/22 14:27 - 8/30/22 13:59
35264038   09/28/2022 16:142996318709/28/2022 16:14CompletedRefill4309/28/2022 16:15 
35264038   10/26/2022 18:023071508910/26/2022 18:02CompletedRefill5410/27/2022 16:15 
35264038   11/21/2022 18:123262634211/21/2022 18:12CompletedRefill6511/21/2022 18:12 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @aboliverABC 

You cam create two column:

Sequence = var a=FILTER('Table','Table'[Customer ID]=EARLIER('Table'[Customer ID])&&'Table'[Registration #]<>BLANK())
return SWITCH(TRUE(),[Trigger_Date]>=MINX(a,[Trigger_Date])&&[Trigger_Date]<MAXX(a,[Trigger_Date])&&[Order #]<>BLANK(),RANKX(FILTER('Table','Table'[Customer ID]=EARLIER('Table'[Customer ID])&&[Trigger_Date]>=MINX(a,[Trigger_Date])&&[Trigger_Date]<MAXX(a,[Trigger_Date])&&[Order #]<>BLANK()),[Trigger_Date],,ASC,Dense),'Table'[Trigger_Date]>=MAXX(a,[Trigger_Date]),RANKX(FILTER('Table','Table'[Customer ID]=EARLIER('Table'[Customer ID])&&'Table'[Trigger_Date]>=MAXX(a,[Trigger_Date])),[Trigger_Date],,ASC,Dense),BLANK())
TAT_MINUTE = var a=FILTER('Table','Table'[Customer ID]=EARLIER('Table'[Customer ID])&&'Table'[Registration #]<>BLANK())
var b=FILTER('Table','Table'[Customer ID]=EARLIER('Table'[Customer ID])&&[Trigger_Date]>=MINX(a,[Trigger_Date])&&[Trigger_Date]<MAXX(a,[Trigger_Date])&&[Order Status]="Completed")
var c=FILTER('Table','Table'[Customer ID]=EARLIER('Table'[Customer ID])&&[Trigger_Date]>=MAXX(a,[Trigger_Date])&&[Order Status]="Completed")
return SWITCH(TRUE(),[Trigger_Date]>=MINX(a,[Trigger_Date])&&[Trigger_Date]<MAXX(a,[Trigger_Date])&&[Order Ship Date]=MINX(b,[Order Ship Date]),DATEDIFF(MINX(A,[Registration Date]),[Order Ship Date],MINUTE),'Table'[Trigger_Date]>=MAXX(a,[Trigger_Date])&&[Order Ship Date]=MINX(c,[Order Ship Date]),DATEDIFF(MAXX(A,[Registration Date]),[Order Ship Date],MINUTE),BLANK())

vxinruzhumsft_0-1672636413636.png

 

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.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @aboliverABC 

You cam create two column:

Sequence = var a=FILTER('Table','Table'[Customer ID]=EARLIER('Table'[Customer ID])&&'Table'[Registration #]<>BLANK())
return SWITCH(TRUE(),[Trigger_Date]>=MINX(a,[Trigger_Date])&&[Trigger_Date]<MAXX(a,[Trigger_Date])&&[Order #]<>BLANK(),RANKX(FILTER('Table','Table'[Customer ID]=EARLIER('Table'[Customer ID])&&[Trigger_Date]>=MINX(a,[Trigger_Date])&&[Trigger_Date]<MAXX(a,[Trigger_Date])&&[Order #]<>BLANK()),[Trigger_Date],,ASC,Dense),'Table'[Trigger_Date]>=MAXX(a,[Trigger_Date]),RANKX(FILTER('Table','Table'[Customer ID]=EARLIER('Table'[Customer ID])&&'Table'[Trigger_Date]>=MAXX(a,[Trigger_Date])),[Trigger_Date],,ASC,Dense),BLANK())
TAT_MINUTE = var a=FILTER('Table','Table'[Customer ID]=EARLIER('Table'[Customer ID])&&'Table'[Registration #]<>BLANK())
var b=FILTER('Table','Table'[Customer ID]=EARLIER('Table'[Customer ID])&&[Trigger_Date]>=MINX(a,[Trigger_Date])&&[Trigger_Date]<MAXX(a,[Trigger_Date])&&[Order Status]="Completed")
var c=FILTER('Table','Table'[Customer ID]=EARLIER('Table'[Customer ID])&&[Trigger_Date]>=MAXX(a,[Trigger_Date])&&[Order Status]="Completed")
return SWITCH(TRUE(),[Trigger_Date]>=MINX(a,[Trigger_Date])&&[Trigger_Date]<MAXX(a,[Trigger_Date])&&[Order Ship Date]=MINX(b,[Order Ship Date]),DATEDIFF(MINX(A,[Registration Date]),[Order Ship Date],MINUTE),'Table'[Trigger_Date]>=MAXX(a,[Trigger_Date])&&[Order Ship Date]=MINX(c,[Order Ship Date]),DATEDIFF(MAXX(A,[Registration Date]),[Order Ship Date],MINUTE),BLANK())

vxinruzhumsft_0-1672636413636.png

 

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.

amitchandak
Super User
Super User

@aboliverABC ,Based on what I got

 

Assuming sequence is working fine, or do small change

 

Sequence =
RANKX(
filter(Combined_Table,
Combined_Table[Customer_Id]=earlier(Combined_Table[Customer_Id])&& not(isblank(Combined_Table [Order_num]))),
Combined_Table [Order_Created_Date], , asc, Dense)

then create a diff


time diff = datediff( coalease( maxx(filter( Combined_Table, Combined_Table[Customer_Id]=earlier(Combined_Table[Customer_Id]) && [Sequence] = earlier([Sequence]) -1 ), [Order_Created_Date]), [Order_Created_Date]) ,[Order_Created_Date], second)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors