Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi, I have a data set with fields Site, Date and Result. I need script to load the nth most recent records based on Date for each Site. I was planning to load the whole dataset and then try to order by Site then Date and use Peek to assign a new ranking field but not sure if there is a cleverer way of doing it? Thanks for your help!!
Hi,
I think your suggestion is already a good start. Check this example for having a flexible way of doing it:
let vLoadNthRecords = 2;
Table:
Load
*
Where Counter <= $(vLoadNthRecords)
;
Load
Date,
Application,
If( Previous( Application ) <> Application,
1,
IF( Previous( Application ) = Application,
Peek( Counter , -1 ) + 1
)
) as Counter
;
Load * Inline [
Date , Application
1-7-2021 , A1
1-7-2021 , A1
1-7-2021 , A1
1-7-2021 , A1
1-7-2021 , A2
1-7-2021 , A2
1-7-2021 , A2
1-7-2021 , A2
1-6-2021 , A3
1-6-2021 , A3
1-6-2021 , A3
1-6-2021 , A3
1-6-2021 , A4
1-6-2021 , A4
1-6-2021 , A4
1-6-2021 , A4
];
Jordy
Climber