Page 1 of 1

Copying Header Record Count to Detail

Posted: Thu Jun 28, 2018 7:20 pm
by chakkara
Hi All,

I have a requirement to copy header count and paste it in its detail records.I need logic to create col4 based on header.

I tried splitting header and detail records and did left outer join with detail record link as primary. I did find duplicates and it got cross joined.

Note : My file contains multiple headers and detail record count will present at individual headers

Sample Input :

Col1 Col2 Col3
H 2 A
D 1 A
D 2 A

H 3 A
D 1 A
D 2 A
D 3 A

H 4 A
D 1 A
D 2 A
D 3 A
D 4 A


Expected Output :

Col1 Col2 Col3 Col4
H 2 A
D 1 A 2
D 2 A 2

H 3 A
D 1 A 3
D 2 A 3
D 3 A 3

H 4 A
D 1 A 4
D 2 A 4
D 3 A 4
D 4 A 4

Thanks in advance.

Re: Copying Header Record Count to Detail

Posted: Fri Jun 29, 2018 9:31 pm
by chakkara
Please help me and provide permanent solution to handle this requirement.

Posted: Fri Jun 29, 2018 10:47 pm
by chulett
:!: Patience, Grasshopper. People help when and if they can and they will provide guidance - it's up to you for the "permanent solution" part.

A bit old but since I've done much the same thing and written it up before, managed to find this post which has some thoughts on approaching this. Hope it helps.

Posted: Mon Jul 02, 2018 1:34 am
by ray.wurlod
So this is marked as resolved.

I presume you learned about how to use stage variables to "remember" things.

Do let us know.

Oh, and by the way, not everyone spends the whole weekend logged in to DSXchange!