Skip to content
Advertisement

Linear extrapolate values down to 0 from variable starting points

I want to build a query which allows me to flexible linear extrapolate a number down to Age 0 starting from the last known value. The table (see below) has two columns, column Age and Volume. My last known volume is 321.60 at age 11, how can I linear extrapolate the 321.60 down to age 0 in annual steps? Also, I would like to design the query in a way which allows the age to change. For example, in another scenario the last volume is at age 27. I have been experimenting with the lead function, as a result I can extrapolate the volume at age 10 but the function does not allow me to extrapolate down to 0. How can I design a query which (A) allows me to linear extrapolate to age 0 and (B) is flexible and allows different starting points for the linear extrapolation.

Advertisement

Answer

If I assume that the value is 0 at 0, then you can use simple arithmetic. This seems to work in your case:

Here is a db<>fiddle

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement