Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I need to loop from 1-20 (for example)
and take a variable such that value of the variable would be : Replace(Replace(Replace(Replace(Replace(.......... 20 times.
Could some one help me with this?
You could try something like:
load * Inline [
Exclude
D
E
F
];
temp:
Load
Key,
Replace(Replace(Replace(If( IterNo()=1, Key,Peek('KeyNew')), FieldValue('Exclude', IterNo()),''), '[',''),']','') as KeyNew
While IterNo()<=FieldValueCount('Exclude');
Load * Inline "
Key
"; FinalExclusion:
Load Key as FinalExclude Resident temp where Len(KeyNew)=0;
NoConcatenate
Final:
Load Distinct Key Resident temp where not Exists(FinalExclude, Key);
Drop Table temp;
Can you share some sample data and what you are expecting to see? Why you need 20 Replace functions? Just wanted to understand?
Hi Vishwarath,
This would be in reference to a the ques posted:
How to exclude possible combinations of few keys?
If you see one of the answers there, this approach is suggested. So, wanted to take that with loop rather than manually writing all that.
Hi,
Perhaps use a for loop with a peek function inside the loop
You could try something like:
load * Inline [
Exclude
D
E
F
];
temp:
Load
Key,
Replace(Replace(Replace(If( IterNo()=1, Key,Peek('KeyNew')), FieldValue('Exclude', IterNo()),''), '[',''),']','') as KeyNew
While IterNo()<=FieldValueCount('Exclude');
Load * Inline "
Key
"; FinalExclusion:
Load Key as FinalExclude Resident temp where Len(KeyNew)=0;
NoConcatenate
Final:
Load Distinct Key Resident temp where not Exists(FinalExclude, Key);
Drop Table temp;
This is incredible!! That actually works and is a great solution in few LOC's.
Thanks a lot