Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
nico_ilog
Partner - Creator II
Partner - Creator II

For each Loop, within the SAME table?

Good Day!!

I'm hoping someone can help me in implementing the following logic inside the Script.

Load

Record1 then

Load Record2 then

Compare Record1 vs Record2 then

## Do some logic

Repeat

How can i do something like that?

Whoever's assistance is much appreciated!

Nico

28 Replies
nico_ilog
Partner - Creator II
Partner - Creator II
Author

Sorry, Wanted to post this to your Name.. My bad!

Good Day Marcus,

Please provide some assistance on the above mentioned.

O can now properly identify the Final Increments.

What is however happening is that fact that the records, which are final increments from the start (i.e. No increments) as situated below.

Po1001

Po1001.1

Po1002 <-- This record is thrown away, because it has no increment.

Po1003

Po1003.1

What can i do to keep those increments? I've been trying some weird combinations, but im not getting it to work?

Please see code below:

//PO

POReworkTableLoad:

LOAD

if(WildMatch(IncrementedPONumber,'*.*') = 1,Right(IncrementedPONumber, len(IncrementedPONumber)-Index(IncrementedPONumber, '.')))  as FinalPoNumber,

    IncrementedPONumber as Increments,

    Left(order_number,6) as LeftOrderNUm,

    order_number ;

LOAD 

    if(NOT WildMatch(order_number,'*.*'),order_number&'.0',order_number)  as IncrementedPONumber,

    order_number

Resident POs  Order By order_number DESC;

POReworkTableFinal:

LOAD

FinalPoNumber as varTestingPORec,

order_number,

if(peek(varTestingPORec,-1) <  [FinalPoNumber],'Final Increment','Previous Increment') as KeepThisPOrecord

RESIDENT POReworkTableLoad

ORDER BY [order_number] DESC;

Not applicable

Use IterNo() and While functions.

marcus_malinow
Partner - Specialist III
Partner - Specialist III

Hi Nico,

try this for your final load

POReworkTableFinal:

NOCONCATENATE LOAD

LeftOrderNUm,

FinalPoNumber as varTestingPORec,

order_number,

if(peek('LeftOrderNUm',-1) = [LeftOrderNUm],'Previous Increment', 'Final Increment') as KeepThisPOrecord

RESIDENT POReworkTableLoad

ORDER BY order_number desc;

nico_ilog
Partner - Creator II
Partner - Creator II
Author

Nope.. didn't work =(

I'll Keep trying!

marcus_malinow
Partner - Specialist III
Partner - Specialist III

Ok what do you see?  I'm assuming that it's the 'Previous Increment', 'Final Increment' that's being fixed here, in which case my code works -

order_number varTestingPORec KeepThisPOrecord LeftOrderNUm
Po10010Previous IncrementPo1001
Po1001.11Final IncrementPo1001
Po10020Final IncrementPo1002
Po10030Previous IncrementPo1003
Po1003.11Final IncrementPo1003
nico_ilog
Partner - Creator II
Partner - Creator II
Author

I tried it? But it did'nt work?

I played around with my previous attempt and this seemed to do the trick in my final load?

POReworkTableFinal:

LOAD

LeftOrderNUm,

FinalPoNumber as varTestingPORec,

order_number,

if(peek(LeftOrderNUm,-1) = LeftOrderNUm,'Previous Increments','Final Increment') as Status

//if(peek(varTestingPORec,-1) <  [FinalPoNumber],'Final Increment','Previous Increment')) as KeepThisPOrecord

RESIDENT POReworkTableLoad

ORDER BY [order_number] DESC;

Drop Table POReworkTableLoad;

It should'nt work? The logic doesnt make sense.. but it does? Let me try your code again!

nico_ilog
Partner - Creator II
Partner - Creator II
Author

(0.o).. lol..

Now it worked perfectly! I knew that i was onto something with my code... just didn't know how to finish it off!

Regards,

Nico Oberholzer

marcus_malinow
Partner - Specialist III
Partner - Specialist III

Looks almost identical to the condition I sent through, aside from the omission of single quotes, but as long as it works...

Can you mark this question as answered now

nico_ilog
Partner - Creator II
Partner - Creator II
Author

Yea, would it make any considerable difference?

Thanks again for the help!