How to interpolate time value pairs?

Hi, i have a database with values and timestamps. I want to interpolate values for explicit timestamps.

To do so i tried doing it with the Math Calculator Plugin but i think it doesn’t seem to work with a date. I have the inspect mode snippet attached.

The Plugin i used: Math Expression Formula Calculator Plugin | Bubble
(Maybe i also dont need a plugin)

Anyone an idea how to fix it?

How are you trying to change the values? My understanding of interpolate would be to add some value.

background:
i have a data thing “device values” that contain values and timestamps. Imagine those are your electriciy meter values. → the values go up while you are consuming energy in you home.

Now i have a long list with many value timestamp pairs and i want to show you your consumption in the month “january” to do so i need the value at the very first second of january first and the value at the very last second of the january 31st. → you usualy dont have values every second so in need to interpolate these values (with a linear function).

In this case therefore i need to have 2 values interpolated: the start and the end value.

To interpolate one value i need the last value before my exact time and the value after. so far so good. And then i need to interpolate with the “classic” interpolation formula

y= value
x= timestamp (for the formula i just use the wanted timestamp for each value)

I did this in the math calculator plugin and it did not work.

Any idea how i can do this so that it works?

If what you’re trying to do is what you explained above then In your chart that displays the data just search for time stamps with month rounded down and month +1 rounded down.

Example today is April 22nd

This will give you every value from
April 1st - 12:00:00
And May 1st 11:59:59

Search will be something like

Search for device values
Date < current date :rounded down
Date > current date + months 1 :rounded down.

1 Like

If you need the meter values stored in the D.B. you could set up a backend trigger to run on each entry at that time to save the current meter reading…but if there is a lot of entries to modify, I’m not sure if it’ll be done at the same exact second.

i want to display the values in a group not in a chart.

if i have the stuff in a chart the chart wouldnt give me the exact value at the time i search (it would just draw a line)

i dont know how to do the calculation in the frontend or backend. From my point of understanding bubble itself is not able to perform such calculations without a plugin correct?

Then do it in a repeating group. Data source search is same as I said above.

Text is created date or just date:formatted as custom
mmmm dd yyyy hh:mm::ss

Why do you need a complex calculation. Bubbles database is saving what you’re asking to down to the second and the search I explained above handled retrieving from the first second to last second of the month…

By all means try to calculate it with toolbox or another plug-in. Seems unnecessary from your explanation unless I’m missing an important detail.

maybe i have not clearly descried what i want to do.

i have 2 values existing in my db. Both values have a time and a value.

What i want to know is a value inbetween the two known values. → linear interpolation.

This has nothing to do with charts or repeating groups.
is this a bit clearer @chris.williamson1996 ? otherwise i could also create a short loom