I have a list with data that are generated by IterNo() fuction but I now would like to make a new field with the numbers in oposit deirection. I would like to solve this in the script but have no clue how to do it. In the example below the field "New field" is what I'm tying to solve. The list of ID is massive....
You could create this new field like this:
Schedule:
Load
ID,
IterNo() as IterNo,
EndDate-StartDate+2-IterNo() as NewField,
Date(StartDate + IterNo() - 1) as BelTime.Date,
Qty
Resident tmpSchedule
While StartDate + IterNo() - 1 <= EndDate;
@laxanders try below
Data:
LOAD ID,
Date
FROM Table;
New:
LOAD *,
if(ID<>previous(ID),1,rangesum(peek('New Field'),1)) as [New Field]
resident Data
order by ID, Date desc;
drop table Data;
generate a similar field by ordering your table in the opposite direction... (order by date desc instead of date asc ? )
"I have a list with data that are generated by IterNo() fuction "
can you post the load statement containing this IterNo() function?
Here comes the IterNo() script.
Schedule:
Load
ID,
IterNo() as IterNo,
Date(StartDate + IterNo() - 1) as BelTime.Date,
Qty
Resident tmpSchedule
While StartDate + IterNo() - 1 <= EndDate;
You could create this new field like this:
Schedule:
Load
ID,
IterNo() as IterNo,
EndDate-StartDate+2-IterNo() as NewField,
Date(StartDate + IterNo() - 1) as BelTime.Date,
Qty
Resident tmpSchedule
While StartDate + IterNo() - 1 <= EndDate;