Template solution help diff between yesterday and today

Hello, I was wondering if it’s possible to calculate the difference of a certain sensors value between yesterday and today?
So when mysensor reports 20 yesterday and 25 today, I expect 5 to see. When its the same value as yesterday it must show 0.

I’ve found the following example but I’m more looking for a template solution? So I can use the difference value also for other things except only in a chart.

chart_type: bar
period: day
days_to_show: 7
type: statistics-graph
entities:
  - sensor.mysensor
stat_types:
  - change

Thanks

It’s not generally possible to access the value of a sensor a given time ago, unless you use an SQL sensor:

An alternative would be to build up your own record using something like this, but with bigger steps: