I have an array in a row that has a start datetime belonging to the first element of the array and an interval which shows the interval between every element in the array in milliseconds. I need to expand the array and have the calculated datetime for every element after it.
Refrain from constant elements. it should be variant in real.
you can use the mv-apply
operator, with the ItemIndex
option.
for example:
datatable(pin_serial_id:long, date_time:datetime, roll:dynamic, interval:long)
[
22021403, datetime(2023-07-26 17:02:59.3820), dynamic([3.54, 3.54, 3.54, 3.54, 3.54]), 100,
22021403, datetime(2023-07-26 17:03:00.3820), dynamic([3.54, 3.54, 3.54, 3.54, 3.54]), 100,
]
| mv-apply with_itemindex = i roll on (
extend date_time = date_time + interval * 1ms * i
)
| project-away i, interval
pin_serial_id | date_time | roll |
---|---|---|
22021403 | 2023-07-26 17:02:59.3820000 | 3.54 |
22021403 | 2023-07-26 17:02:59.4820000 | 3.54 |
22021403 | 2023-07-26 17:02:59.5820000 | 3.54 |
22021403 | 2023-07-26 17:02:59.6820000 | 3.54 |
22021403 | 2023-07-26 17:02:59.7820000 | 3.54 |
22021403 | 2023-07-26 17:03:00.3820000 | 3.54 |
22021403 | 2023-07-26 17:03:00.4820000 | 3.54 |
22021403 | 2023-07-26 17:03:00.5820000 | 3.54 |
22021403 | 2023-07-26 17:03:00.6820000 | 3.54 |
22021403 | 2023-07-26 17:03:00.7820000 | 3.54 |