Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Need help in the script - Duplicate the value

Hi,

As I need to manage the as in the below requirement in the script.

The schenorio is One Invoice number it contains 10 consignments and the first record only has "Itally" as I need to fill the "Itally" to the 10 consignments

Current table value is like as in the below:


Invoice NumberConsignment NumberCountry
ADY890781Itally
ADY890782
ADY890783
ADY890784
ADY890785
ADY890786
ADY890787
ADY890788
ADY890789
ADY8907810

Required as like in the belwo:

Invoice NumberConsignment NumberCountry
ADY890781Itally
ADY890782Itally
ADY890783Itally
ADY890784Itally
ADY890785Itally
ADY890786Itally
ADY890787Itally
ADY890788Itally
ADY890789Itally
ADY8907810Itally

Chriss

1 Solution

Accepted Solutions
Not applicable
Author

I´m glad it works. The one you wrote was this:

If(Peek(Inv=Peek(shipno)),Peek(Name),Name) as Test

As you can see, your peek brackets are wrong placed, and also, you are comparing the field Inv with the previous shipno field. The correct way is to compare the same field:     Inv=Peek(Inv)

It's what swuehl and Henric Cronström wrote, I just made the solution applied to your example.

Bye!

View solution in original post

8 Replies
hic
Former Employee
Former Employee

Load

     [Invoice Number],

     [Consignment Number],

     If([Invoice Number]=Peek([Invoice Number]),Peek(Country),Country) as Country

From ...

HIC

swuehl
MVP
MVP

Try something like

LOAD

     InvoiceNumber,

     ConsignmentNumber,

     If( InvoiceNumber=peek(InvoiceNumber),peek(Country), Country) as Country

FROM Table ORDER BY InvoiceNumber, ConseignmentNumber;

Not applicable
Author

Hi Henric and Swuehl,

Thanks for your reply, but the above expression is not solved it, could you please help me...

Test:

LOAD * Inline [

Inv,shipno,Name

LTN0813,1,TOM

LTN0813,2,TOM

LTN0813,3,TOM

LTN0813,4,TOM

LTN0813,5,TOM

LTN0813,6,TOM

LTN1000,1,TOM

LTN1000,2

LTN1000,3

LTN1000,4

LTN1000,5

LTN1000,6

];

LOAD

Inv,

shipno,

Name,

If(Peek(Inv=Peek(shipno)),Peek(Name),Name) as Test

Resident Test Order by Inv,shipno, Name;

Regards

Chriss

Not applicable
Author

Try this way:

Test:

LOAD

Inv,

shipno,

If(Inv=Peek(Inv),Peek(Name),Name) as Name;

LOAD * Inline [

Inv,shipno,Name

LTN0813,1,TOM

LTN0813,2,TOM

LTN0813,3,TOM

LTN0813,4,TOM

LTN0813,5,TOM

LTN0813,6,TOM

LTN1000,1,TOM

LTN1000,2

LTN1000,3

LTN1000,4

LTN1000,5

LTN1000,6

];

It seems to work.

swuehl
MVP
MVP

Yes, check your line with the peek functions, that's not what we suggested.

Not applicable
Author

HI Iosu Garcia,

Thanks a lot.... its working fine now, could you please explain me why the previous one is not working fine, the logic and the expression also correct where I made the mistake.

Thanks for your reply swuehl,   but the column names only I changed in the inline expression, please correct me if I am wrong.

Regards

Chriss

Not applicable
Author

I´m glad it works. The one you wrote was this:

If(Peek(Inv=Peek(shipno)),Peek(Name),Name) as Test

As you can see, your peek brackets are wrong placed, and also, you are comparing the field Inv with the previous shipno field. The correct way is to compare the same field:     Inv=Peek(Inv)

It's what swuehl and Henric Cronström wrote, I just made the solution applied to your example.

Bye!

Not applicable
Author

Hi All,

Thanks for your valueable support, now I understand where I made the mistake.

Thanks again for your valuable support.

Regards

Chriss