Skip to main content

Hello all, would appreciate someone helping me with this calculation, I am a new Tableau user self learning.

 

I have the following source, I need to make a new calculated field in source where it calculates the time spent of each Order Outlet ID from its previous order status.

 

Created Date, which contains time also, is basically the Time stamp of the record.

 

The records for each Order outlet ID are not under each other, many can be in between.

 

The calculation must do the following

 

for every Order Outlet ID

calculate the difference (convert to minutes) of the Created Date & Time Field (timestamp)

for the previous Order Status for that same Order Outlet ID (Order Status -1)

of course those with order status =1 won't have a value since no previous value, so must be zero.

 

 Calculating Time Spent ( Record value subtraction) 

 

Appreciate your help!

7 answers
  1. Mar 18, 2021, 8:16 PM

    Hello Ala,

     

    Time Difference:

    IF FIRST()=0 THEN 0 ELSE

    LOOKUP(ATTR([Created Date]),0)-LOOKUP(ATTR([Created Date]),-1) END

    Format as h:mm:ss - Also this is a table calculation so the settings for it should be (right-click the pill and select Edit Table Calc):

    Hello Ala, Time Difference:IF FIRST()=0 THEN 0 ELSELOOKUP(ATTR([Created Date]),0)-LOOKUP(ATTR([Created Date]),-1) ENDFormat as h:mm:ss - Also this is a table calculation so the settings for it shouldNumber of Minutes:

    [Time Difference]*(60*24)

    Returns the following for the example Order Outlet ID's:

    Screen Shot 2021-03-18 at 1.16.38 PMBest, Don

0/9000