
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If statement using Peek
Within Script I wish to use the following formula
if([Stock Qty]-[Sales Qty (All)]>Peek([Stock Qty],-1),'Restocked','') as RestockedEVER
Below is my current script which I thought should work however i only get null values for [RestockedEVER]
NEWTABLEx:
Load Item_ID,
[Stock Qty],
[Sales Qty (All)],
[Reporting Date]
Resident Data_Values_New_2
order by [Item_ID], [Reporting Date];
NEWTABLEy:
NoConcatenate Load Item_ID,
[Reporting Date],
if([Stock Qty]-[Sales Qty (All)]>Peek([Stock Qty],-1),'Restocked','') as RestockedEVER
Resident NEWTABLEx;
NEWTABLE2:
mapping Load Item_ID,
MAX(RestockedEVER) As RestockedEVER
Resident NEWTABLEy
Group by Item_ID;
Example Data
Item_ID | Stock Qty | Sales Qty (All) | Reporting Date |
1 | 100 | 0 | 31/01/2019 |
1 | 90 | 10 | 28/02/2019 |
1 | 120 | 10 | 31/03/2019 |
1 | 110 | 10 | 30/04/2019 |
1 | 100 | 10 | 31/05/2019 |
2 | 100 | 0 | 31/01/2019 |
2 | 90 | 10 | 28/02/2019 |
2 | 120 | 10 | 31/03/2019 |
2 | 110 | 10 | 30/04/2019 |
2 | 100 | 10 | 31/05/2019 |
3 | 100 | 10 | 31/01/2019 |
3 | 90 | 10 | 28/02/2019 |
3 | 80 | 10 | 31/03/2019 |
3 | 70 | 10 | 30/04/2019 |
3 | 60 | 10 | 31/05/2019 |
4 | 100 | 10 | 31/01/2019 |
4 | 90 | 10 | 28/02/2019 |
4 | 80 | 10 | 31/03/2019 |
4 | 70 | 10 | 30/04/2019 |
4 | 60 | 10 | 31/05/2019 |
Accepted Solutions


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Instead of Peek([Stock Qty],-1) use Previous([Stock Qty])


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Instead of Peek([Stock Qty],-1) use Previous([Stock Qty])
