Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How can i get the value of before field in the dynamic table?

I working with dynamic table, and have two columns, 1st is start time, 2nd is finish time, and i need a new column with the diference between start time and before finish time, how can i get the value of finish time of before row, i tried to use above(field_name) but i didnt have sucessful.....

Tks!!!l

1 Solution

Accepted Solutions
Not applicable
Author

Hi ealeixo,

Have you tried the previous function? This function is used in the script and the only thing to make sure is that your table is sorted correct when applying previous. Calculating this difference in the script makes you more free when it comes to sorting columns in tables.

Shift_tmp:
LOAD Shift,
time(StartTime,'hh:mm:ss') as StartTime,
time(FinishTime,'hh:mm:ss') as FinishTime
FROM StartTime_FinishTime.xls (biff, embedded labels, table is Blad1$)
;

Shift:
LOAD *,
previous(FinishTime) as PrevFinishTime,
if((StartTime-previous(FinishTime))>0,time((StartTime-previous(FinishTime)),'hh:mm:ss'),time(0,'hh:mm:ss')) as DiffStartPrevFinish
RESIDENT Shift_tmp
ORDER BY StartTime;

DROP TABLE Shift_tmp;

This is the data I used in Excel:

ShiftStartTimeFinishTime
A08:15:0009:01:05
E13:25:0014:19:00
D11:14:3212:08:12
C10:05:2410:55:52
B09:13:4209:50:00


Table in QV:

Shift StartTime FinishTime DiffStartPrevFinish
A08:15:0009:01:0500:00:00
B09:13:4209:50:0000:12:37
C10:05:2410:55:5200:15:24
D11:14:3212:08:1200:18:40
E13:25:0014:19:0001:16:48


best regards,

Johan Tell, Climber

View solution in original post

3 Replies
jbeierschmitt
Contributor III
Contributor III

If you sort the table you should be able to utilize the PREVIOUS function to select the row immediately above the record; the key is to sort that field in descending order...

[ code ]

DependentDemand:
%BOMReference_Key & [STPO.Item_POSNR] AS %BOMReferencePOSNR_Key,
if(date#([STPO.Valid From_DATUV],'YYYY-MM-DD') = MAXDATE,$(vToday),previous([STPO.Valid From_DATUV])-1) AS [STPO.Valid To_PREVIOUS],
*
RESIDENT
EXPO_BOM_2_MAT
ORDER BY
%BOMReference_Key ASC,
[STPO.Item_POSNR] ASC,
[STPO.Valid From_DATUV] DESC;















le EXPO_BOM_2_MAT;















le EXPO_BOM_2_MAT;

le EXPO_BOM_2_MAT;

















[ /code ]













Not applicable
Author

Hi ealeixo,

Have you tried the previous function? This function is used in the script and the only thing to make sure is that your table is sorted correct when applying previous. Calculating this difference in the script makes you more free when it comes to sorting columns in tables.

Shift_tmp:
LOAD Shift,
time(StartTime,'hh:mm:ss') as StartTime,
time(FinishTime,'hh:mm:ss') as FinishTime
FROM StartTime_FinishTime.xls (biff, embedded labels, table is Blad1$)
;

Shift:
LOAD *,
previous(FinishTime) as PrevFinishTime,
if((StartTime-previous(FinishTime))>0,time((StartTime-previous(FinishTime)),'hh:mm:ss'),time(0,'hh:mm:ss')) as DiffStartPrevFinish
RESIDENT Shift_tmp
ORDER BY StartTime;

DROP TABLE Shift_tmp;

This is the data I used in Excel:

ShiftStartTimeFinishTime
A08:15:0009:01:05
E13:25:0014:19:00
D11:14:3212:08:12
C10:05:2410:55:52
B09:13:4209:50:00


Table in QV:

Shift StartTime FinishTime DiffStartPrevFinish
A08:15:0009:01:0500:00:00
B09:13:4209:50:0000:12:37
C10:05:2410:55:5200:15:24
D11:14:3212:08:1200:18:40
E13:25:0014:19:0001:16:48


best regards,

Johan Tell, Climber

Not applicable
Author

johan,

I understood your solution, but i need to do this in the EXPRESSION, because we will use some selections and update the difference.

tks a lot!!