Announcements
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

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)
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

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)
Contributor II
Author
Hi,