Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for
Did you mean:
Contributor II

loop with multiple condition

Hi,

1. I have requirement we  need to pick the Rate value column on the maxdate for six ID combination.

2. wherever there is no Rate Value i.e Rate is Null it should repeat the loop atleast for the 6 times of maxdate.

for eg: if Rate is Null it will go and check 6th ID max date and display the value ,if 6th ID is Null then will check for 5th ID Maxdate Rate value,and if 5th ID is Null will check for 4th Maxdate Rate Value and so on.....

Do we need to use Peek or Alt function.

I hope its clear the requirement.

Please find the attached Data set.

Regards

Labels (3)

• sunny_talwar

1 Solution

Accepted Solutions

Think this way?

Table:
ID1,
ID2,
ID3,
ID4,
ID5,
ID6,
AutoNumber(Iterno(), ID1&ID2&ID3&ID4&ID5&ID6) as ID
From Table;

LET vMax6Date = Peek('ID', 6, 'Table');

If Len(RateValue)=0 Then
For i=1 to 6
Table_6_Record:
Load Max(DateField) as Max_6_Date from Table Where ID='\$(vMax6Date)';
Left Join(Table_6_Record)
ID1,
ID2,
ID3,
ID4,
ID5,
ID6,
ID,
If(IsNull(RateValue) and ID=6, RateValue, Peek('RateValue_Copy')+1) as RateValue_Copy
Resident Table;
Next i
End If

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
4 Replies
Contributor II
Author
Hi,

@sunny_talwar can you please have a look .

Regards

Think this way?

Table:
ID1,
ID2,
ID3,
ID4,
ID5,
ID6,
AutoNumber(Iterno(), ID1&ID2&ID3&ID4&ID5&ID6) as ID
From Table;

LET vMax6Date = Peek('ID', 6, 'Table');

If Len(RateValue)=0 Then
For i=1 to 6
Table_6_Record:
Load Max(DateField) as Max_6_Date from Table Where ID='\$(vMax6Date)';
Left Join(Table_6_Record)
ID1,
ID2,
ID3,
ID4,
ID5,
ID6,
ID,
If(IsNull(RateValue) and ID=6, RateValue, Peek('RateValue_Copy')+1) as RateValue_Copy
Resident Table;
Next i
End If

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Contributor II
Author
Hi,

While loading this code i am getting error .

Regards
Contributor II
Author
Hi,

Thanks i rectified the error thanks for the solution really appreciated.

Regards
Community Browser