Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
Talk to Experts Tuesday, Live Q&A, September 22: Moving from QlikView to Qlik Sense. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Contributor
Contributor

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
Highlighted

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

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)

View solution in original post

4 Replies
Highlighted
Contributor
Contributor

Hi,

@sunny_talwar can you please have a look .

Regards
Highlighted

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

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)

View solution in original post

Highlighted
Contributor
Contributor

Hi,

While loading this code i am getting error .

Regards
Highlighted
Contributor
Contributor

Hi,

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

Regards