Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
anisha_nan
Contributor II
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)
1 Solution

Accepted Solutions
Anil_Babu_Samineni

Think this way?


Table:
Load RateValue,
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)
Load RateValue,
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

View solution in original post

4 Replies
anisha_nan
Contributor II
Contributor II
Author

Hi,

@sunny_talwar can you please have a look .

Regards
Anil_Babu_Samineni

Think this way?


Table:
Load RateValue,
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)
Load RateValue,
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
anisha_nan
Contributor II
Contributor II
Author

Hi,

While loading this code i am getting error .

Regards
anisha_nan
Contributor II
Contributor II
Author

Hi,

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

Regards