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

Creating two fields from a field based on its field value

Hello

I have a table where there is a "key" field with two values 'AB' or 'LA' this creates two rows for every item i have.

I want to load them as only one line, 

Original output:

Purch.Doc.ItemCCDeliv. DateQuantityQty Red.
450008335500010AB2019-03-0212,00011,000
450008335500020AB2019-03-0210,00010,000
450008335500030AB2019-03-0213,00013,000
450008335500040AB2019-03-026,0006,000
450008335500050AB2019-03-026,0006,000
450008335500060AB2019-03-026,0006,000
450008335500010LA2019-03-0411,00011,000
450008335500020LA2019-03-0410,00010,000
450008335500030LA2019-03-0413,00013,000
450008335500040LA2019-03-046,0006,000
450008335500050LA2019-03-046,0006,000
450008335500060LA2019-03-046,0006,000
450008335500070LA2019-04-043,0003,000
450008335500080LA2019-03-123,0003,000
450008335500090LA2019-03-123,0003,000
450008335500100LA2019-03-123,0003,000
450008335500110LA2019-03-221,0001,000

 

//The Load Scripts have been adjsuted so its easier to see, if there are any typos they are only on this post the script runs without error, i just dont get the expected output.

 

LOAD

 PO,
Item,
PO&'-'& Item as CCPOrad,
CC
"Delivery Date"
IF(CC='AB', "Delivery Date") as "AB Date",
IF(CC='LA', "Delivery Date") as "LA Date",
IF(CC='AB', Quantity) as ABQTY,
IF(CC='LA',Quantity) as LAQTY,
IF(CC='AB',"Quanitity Reduced") as ABQTYred,
IF(CC='LA',"Quanitity Reduced") as LAQTYred

EKES:

Load
PO,
Item,
CCPOrad,
"LA Date",
"AB Date",
ABQTY,
LAQTY,
ABQTYred,
LAQTYred,
ABQTY - ABQTYred as "Open ABQTY",
LAQTY - LAQTYred as "Open LAQTY"

Resident EKES;

Output after my attempts:
(Reduced to 8 Lines)

POItemCCPOradAB DateLA DateOpen ABQTYOpen LAQTY
4500083355000204500083355-000202019-03-02-4-
4500083355000204500083355-00020-2019-03-04-4
4500083355000304500083355-000302019-03-02-4-
4500083355000304500083355-00030-2019-03-04-4
4500083355000404500083355-000402019-03-02-4-
4500083355000404500083355-00040-2019-03-04-4
4500083355000604500083355-000602019-03-02-4-
4500083355000604500083355-00060-2019-03-04-4

 

Desired Output:


POItemCCPOradAB DateLA DateOpen ABQTYOpen LAQTY
4500083355000204500083355-000202019-03-022019-03-0444
4500083355000304500083355-000302019-03-022019-03-0444
4500083355000404500083355-000402019-03-022019-03-0444
4500083355000604500083355-000602019-03-022019-03-0444

 

I'm probably going about this the wrong way and I could use some help.
Let me know if you need any more information or actual QVD data, and I'll see what I can do.

Labels (3)
1 Solution

Accepted Solutions
lironbaram
Partner - Master III
Partner - Master III

hi 

have you should try this ,

EKES:

Load
PO,
Item,
CCPOrad,
max("LA Date") as "LA Date",
max("AB Date") as "AB Date",
sum(ABQTY)        as ABQTY,
sum(LAQTY)        as LAQTY,
sum(ABQTYred)        as ABQTYred,
sum(LAQTYred)        as LAQTYred,
sum(ABQTY - ABQTYred) as "Open ABQTY",
sum(LAQTY - LAQTYred) as "Open LAQTY"

Resident EKES

group by PO,
Item,
CCPOrad;

View solution in original post

3 Replies
agigliotti
Partner - Champion
Partner - Champion

could you send us the qvd files to look at?

lironbaram
Partner - Master III
Partner - Master III

hi 

have you should try this ,

EKES:

Load
PO,
Item,
CCPOrad,
max("LA Date") as "LA Date",
max("AB Date") as "AB Date",
sum(ABQTY)        as ABQTY,
sum(LAQTY)        as LAQTY,
sum(ABQTYred)        as ABQTYred,
sum(LAQTYred)        as LAQTYred,
sum(ABQTY - ABQTYred) as "Open ABQTY",
sum(LAQTY - LAQTYred) as "Open LAQTY"

Resident EKES

group by PO,
Item,
CCPOrad;

Laxbax
Contributor II
Contributor II
Author

Thanks, This did the trick.

I was trying to get this to work before but I had no experience with group by clause in resident.

+100