Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
surendraj
Specialist
Specialist

How to get same vendor name...

Hello Community,

I have 4 fields.(sup_key,ven_key,ven_name,sale).

1.My scenario is when sup_key=ven_key,The coresponding ven_name should be obtained.

2.when ven_key<>sup_key,the above same ven_name should be obtained for the all the sup_key and ven_key.

Please find the attached snaps, with my input data and desired output.

input:

input.png

Out put should be

output.png

---Surendra

1 Solution

Accepted Solutions
vinieme12
Champion III
Champion III

As Below, next time please post accurate output!!

temp:

LOAD *

INLINE [

    sup_key, ven_key, ven_name, sale

    120, 120, rwq, 225

    120, 135, ewe, 111

    120, 135, ewe, 534

    135, 135, ped, 706

    135, 215, eur, 831

    135, 215, eur, 275

    135, 215, eur, 132

    135, 215, eur, 346

    140, 144, vvv, 566

    140, 140, gfd, 480

    140, 154, mkl, 964

    140, 154, mkl, 616

    140, 154, mkl, 154

];

NoConcatenate

FACT:

LOAD *,

if(sup_key=ven_key,ven_name,if(sup_key=Previous(sup_key),peek(new_ven_name),ven_name)) as new_ven_name

Resident temp

Order by sup_key,ven_key;

Drop Table temp;

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

15 Replies
vinieme12
Champion III
Champion III

Try

LOAD *,

if(sup_key=ven_key,ven_name,if(sup_key=Previous(sup_key),peek(new_ven_name),ven_name)) as new_ven_name

;

LOAD *

INLINE [

    sup_key, ven_key, ven_name, sale

    120, 120, rwq, 225

    120, 135, ewe, 111

    120, 135, ewe, 534

    135, 135, ped, 706

    135, 215, eur, 831

    135, 215, eur, 275

    135, 215, eur, 132

    135, 215, eur, 346

    140, 144, vvv, 566

    140, 140, gfd, 480

    140, 154, mkl, 964

    140, 154, mkl, 616

    140, 154, mkl, 154

];

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
surendraj
Specialist
Specialist
Author

Thanks for reply.It works for sup_keys 120 and 135..

Its not working for 140.

Here i want new_ven_name as gfd for sup_key=140

op.png

omkarvamsi
Creator
Creator

Hi Surendra,

Please try with below logic

maptoven_name:

Mapping

LOAD sup_key,   

     ven_name

   

FROM

(ooxml, embedded labels, table is Sheet2)

where sup_key=ven_key;

maindata:

LOAD sup_key,

     ven_key,

     ApplyMap('maptoven_name',sup_key,ven_name) as MapVenName,

     sale

FROM

(ooxml, embedded labels, table is Sheet2);

adamdavi3s
Master
Master

LOAD *,

if(sup_key=ven_key,ven_name,if(sup_key=Previous(sup_key),previous(ven_name),ven_name)) as new_ven_name

;

LOAD *

INLINE [

    sup_key, ven_key, ven_name, sale

    120, 120, rwq, 225

    120, 135, ewe, 111

    120, 135, ewe, 534

    135, 135, ped, 706

    135, 215, eur, 831

    135, 215, eur, 275

    135, 215, eur, 132

    135, 215, eur, 346

    140, 144, vvv, 566

    140, 140, gfd, 480

    140, 154, mkl, 964

    140, 154, mkl, 616

    140, 154, mkl, 154

];

vinieme12
Champion III
Champion III

Check your Original Post the value 140(sup)  and 144(ven) is before the row when both keys match the output matches the original table you posted..

please check again

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
vinieme12
Champion III
Champion III

See the same output in table viewer (CTRL+T),, table box will only sort on one dimension

peek().PNG

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
vinieme12
Champion III
Champion III

if you still have doubts post an excel sample!!

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
adamdavi3s
Master
Master

This is the issue with using previous without an order by, but I can't see anyway you could order this simply to ensure the correct result.

Omkar's solution above is probably the most robust....

surendraj
Specialist
Specialist
Author

Hi Vineeth,

yes it will be like that only in some cases,
but I need the ven_name only when ever my sup_key=ven_key.That perticular ven_name is applicable to all rows for 140

In case of 140,the ven_name is gfd.so I want gfd for all rows..