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

Duplicate record if it gets status -1

If Status -1, clone the fields cod, date, status, id, qty. Changing the Status to '0', and Qty 'Positive'

If the Status is -1, it duplicates the line, changing it to positive.
Edit Qty and Status to positive and duplicate the line
id, date, status, ordem, qtde
2360 12/11/2012 17:33:13 -1 201221 -24
2360 12/11/2012 17:33:13 -1 201222 -84
2360 12/11/2013 17:38:13 -1 201228 -24
2360 12/11/2013 17:38:13 -1 201227 -84
How should it look


 

cod date Status id qtde
2360 11/12/2012 17:33 -1 201221 -24
2360 11/12/2012 17:33 -1 201222 -84
2360 11/12/2013 17:38 -1 201228 -24
2360 11/12/2013 17:38 -1 201227 -84
2360 11/12/2012 17:33 0 201221 24
2360 11/12/2012 17:33 0 201222 84
2360 11/12/2013 17:38 0 201228 24
2360 11/12/2013 17:38 0 201227 84
Paula Santos
vitória - ES
Labels (3)
1 Solution

Accepted Solutions
BrunPierre
Master
Master

Hi, do this.

Data:
LOAD id, 
     date, 
     status, 
     ordem, 
     qtde
FROM SourceTable;

Positives:
LOAD id, 
     date, 
     not Sign(status) as status, 
     ordem,  
     Fabs(qtde) as qtde

Resident Data
Where status = -1;

View solution in original post

7 Replies
BrunPierre
Master
Master

Hi, do this.

Data:
LOAD id, 
     date, 
     status, 
     ordem, 
     qtde
FROM SourceTable;

Positives:
LOAD id, 
     date, 
     not Sign(status) as status, 
     ordem,  
     Fabs(qtde) as qtde

Resident Data
Where status = -1;
MayilVahanan

Hi 

Try like below

Source:
Load id, date, status, ordem, qtde from ursource;

Load id, date, 0 as status, ordem, fabs(qtde) as qtde resident Source where status = -1;

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Paula1
Creator
Creator
Author

 BrunPierre ,
If Status -1, clone the fields cod, date, status, id, qty. Changing the Status to '0', and Qty 'Positive'

I would like to leave the lines negative and duplicate the records and leave both, as in the example below
cod date Status id qtde
2360 11/12/2012 17:33 -1 201221 -24
2360 11/12/2012 17:33 -1 201222 -84
2360 11/12/2013 17:38 -1 201228 -24
2360 11/12/2013 17:38 -1 201227 -84
2360 11/12/2012 17:33 0 201221 24
2360 11/12/2012 17:33 0 201222 84
2360 11/12/2013 17:38 0 201228 24
2360 11/12/2013 17:38 0 201227 84

 

Paula Santos
vitória - ES
Paula1
Creator
Creator
Author

PREVIEW
 

I would like to leave the lines negative and duplicate the records and leave both, as in the example below
cod date Status id qtde
2360 11/12/2012 17:33 -1 201221 -24
2360 11/12/2012 17:33 -1 201222 -84
2360 11/12/2013 17:38 -1 201228 -24
2360 11/12/2013 17:38 -1 201227 -84
2360 11/12/2012 17:33 0 201221 24
2360 11/12/2012 17:33 0 201222 84
2360 11/12/2013 17:38 0 201228 24
2360 11/12/2013 17:38 0 201227 84

 

 

Paula Santos
vitória - ES
BrunPierre
Master
Master

@Paula1 For me, it definitely works well.

BrunPierre_0-1683722699116.png

Paula1
Creator
Creator
Author

  • Congratulations Bruno Pierre. Sorry my friend, It confuses with the columns. And 100% right. Congratulations on your competence.
Paula Santos
vitória - ES
Paula1
Creator
Creator
Author

Data:
LOAD id, 
     date, 
datex,
     status, 
     ordem, 
     qtde
FROM SourceTable;

Positives:
LOAD id, 
     date, 
     datex,
     not Sign(status) as status, 
     ordem,  
     Fabs(qtde) as qtde

Resident Data
Where status = -1;
How do I change the date to datax in this script that is correct.
cod date datex Status id qtde
2360 11/12/2012 17:33 15/12/2012 17:33 -1 201221 -24
2360 11/12/2012 17:33 15/12/2012 17:33 -1 201222 -84
2360 11/12/2013 17:38 15/12/2013 17:38 -1 201228 -24
2360 11/12/2013 17:38 15/12/2013 17:38 -1 201227 -84
2360 15/12/2012 17:33 15/12/2012 17:33 0 201221 24
2360 15/12/2012 17:33 15/12/2012 17:33 0 201222 84
2360 15/12/2013 17:38 15/12/2013 17:38 0 201228 24
2360 15/12/2013 17:38 15/12/2013 17:38 0 201227 84
Paula Santos
vitória - ES