I'm gathering data from an Excel file in which there's just some values, by date and hour.
During load I've to fill all the rows between two date/hours, automatically creating ALL the inter-current date/hours; I've also to divide the next value by all the inter-current rows count.
The problem are:
how to fill all rows creating all the inter-current date/hours
how to split the last values dividing them by the number of Days/Hours Between two dates, using this solution
I've to fill all the gaps between - for example - "03/11/2017 10:00" and "30/11/2017 10:00" with all missed date and hours inter-current, and splitting the last values (15.320 for example) by all the gap-filled rows.
To solve the problem I've followed a previous suggestion from a community member:
// test data
Floor(rand()*100) as Value1,
Floor(rand()*100) as Value2
// add DateTo
RowNo() as Id, Value1, Value2,
Date, Alt(Peek(Date), Date) as DateTo
Order By Date desc;
DROP Table S;
// add Hours between Date....DateTo
Timestamp(Date + (IterNo()-1) / (24)) as DateTime
While (Date + (IterNo()-1) / (24)) <= (DateTo);
DROP Table S1;
Is it a good way to solve both my problems? It doesn't seem work completely good, maybe something has to be refined.
The script copies the values to all the dates/hours between Date and DateTo. The method to generate the "missing" rows is correct. if you want to divide the value, you'd need to determine the number of hours between Date and DateTo and divide the values accordingly