Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Update field valu in load script

I have a table with timestamps that I want to load, TimestampStart and TimestampEnd. Sometimes the TimestampEnd has a time that is before the time in TimestampStart, se examples in table below marked red.

I would like to correct this in the load script, so if TimestampStart is less than TimestampEnd, TimestampStart should be updated to TimestampEnd and TimestampEndt should be updated to TimestampStart, the values should change places. Hope anyone can help me to get the script correct.

TimestampStart TimestampEnd
2010-01-01 00:10 2010-01-01 00:40
2010-01-01 00:10 2010-01-01 00:15
2010-01-01 00:15 2010-01-01 00:20
2010-01-01 00:30 2010-01-01 00:35
2010-01-01 00:30 2010-01-01 00:35
2010-01-01 00:30 2010-01-01 00:55
2010-01-01 00:30 2010-01-01 00:25
2010-01-01 00:30 2010-01-01 00:35
2010-01-01 00:30 2010-01-01 00:35
2010-01-01 00:30 2010-01-01 12:35
2010-01-01 00:45 2010-01-01 00:30
2010-01-01 00:30 2010-01-01 00:35
2010-01-01 00:30 2010-01-01 00:55
2010-01-01 00:30 2010-01-01 00:35

Best Regards

Mårten

1 Solution

Accepted Solutions
tresesco
MVP
MVP

Try like:

Load

     If( TimeStampStart>TimeStampEnd,  TimeStampEnd, TimeStampStart) as TimeStampStart,

     If( TimeStampStart>TimeStampEnd,  TimeStampStart, TimeStampEnd) as TimeStampEnd

From <>;

View solution in original post

4 Replies
tresesco
MVP
MVP

Try like:

Load

     If( TimeStampStart>TimeStampEnd,  TimeStampEnd, TimeStampStart) as TimeStampStart,

     If( TimeStampStart>TimeStampEnd,  TimeStampStart, TimeStampEnd) as TimeStampEnd

From <>;

sujeetsingh
Master III
Master III

you can follow the nested if conditions as per Tresco.

its_anandrjs
Champion III
Champion III

Hi,

Load another table

Load

TimestampStart,

TimestampEnd,

if( TimestampStart > TimestampEnd, TimestampEnd,TimestampStart) as TimestampStartNew

From Source;

Ex:-

A:

LOAD

Timestamp#(TimestampStart,'YYYY-DD-MM hh:mm') as TimestampStart,

Timestamp#(TimestampEnd,'YYYY-DD-MM hh:mm') as TimestampEnd;

LOAD * Inline

[

TimestampStart,     TimestampEnd

2010-01-01 00:10,     2010-01-01 00:40

2010-01-01 00:10,     2010-01-01 00:15

2010-01-01 00:15,     2010-01-01 00:20

2010-01-01 00:30,     2010-01-01 00:35

2010-01-01 00:30,     2010-01-01 00:35

2010-01-01 00:30,     2010-01-01 00:55

2010-01-01 00:30,     2010-01-01 00:25

2010-01-01 00:30 ,    2010-01-01 00:35

2010-01-01 00:30 ,    2010-01-01 00:35

2010-01-01 00:30,     2010-01-01 12:35

2010-01-01 00:45 ,    2010-01-01 00:30

2010-01-01 00:30 ,    2010-01-01 00:35

2010-01-01 00:30 ,    2010-01-01 00:55

2010-01-01 00:30 ,    2010-01-01 00:35

];

NoConcatenate

B:

LOAD

TimestampStart,     TimestampEnd,

if( TimestampStart > TimestampEnd, TimestampEnd,TimestampStart) as TimestampStartNew,

if( TimestampStart > TimestampEnd, TimestampStart,TimestampEnd) as TimestampEndNew

Resident A;

DROP Table A;

timestend.png

Regards

Anand

Not applicable
Author

Thanks all, now it worked.

Best regards

Mårten