Hi everyone,
The title of my topic is not really easy to understand so let me try to explain with a simple example.
I have the following data from an API call:
ID, execution_date, value
#A, 2023-02-01 8:00am, 1000
#A, 2023-02-01 18:00am, 900
#A, 2023-02-01 19:00am, 1200
#A, 2023-02-03 12:00am, 1300
The result I need is:
#A, 2023-02-01, 1200
#A, 2023-02-02, 1200
#A, 2023-02-03, 1300
So, first I need to group by day and find the last value of the day (with the max(execution_date)).
#A, 2023-02-01, 1200
#A, 2023-02-03, 1300
Then I need to expand to all days between the min and max date and fill empty values with the previous value.
#A, 2023-02-01, 1200
#A, 2023-02-02, 1200
#A, 2023-02-03, 1300
Do you have any idea how I could handle this? I started with a group by ID and day(execution_date) with a max(execution_date) aggregation but I don’t know how to merge this list with the raw data from the API call.
Thank you all for your help