Adjust column value based on difference between 2 dates
I have sales data at the start of every month in a quarter.
Example: For 22-Q1 quarter, I have sales on 3 dates (1st Jan, 1st Feb and 1st March)
| Date | Country | Region | Sales |
|---|---|---|---|
| 01/01/2022 | UK | EMEA | 100,000 |
| 02/01/2022 | UK | EMEA | 170,000 |
| 03/01/2022 | UK | EMEA | 120,000 |
| 01/01/2022 | US | AMS | 90,000 |
| 02/01/2022 | US | AMS | 110,000 |
| 03/01/2022 | US | AMS | 160,000 |
My requirement is to extrapolate the Sales data between the 2 given dates based on difference between the 2 dates and concatenate them to the same table.
For example for 2nd Jan, I calculate the date difference between 1st Jan and 1st Feb, which is 31 days and increment Sales amount by (1/31) and for 3rd Jan, I increment Sales amount by (2/31).. so on until 31st Jan.
After the month change, the date difference needs to be recalculated between 1st Feb and 1st March and similar increment on Sales needs to be applied
Comments
Post a Comment