Fixes counter value calculation

Need the previous value stored in the database, because `latest_value`
is a diff, not the actual value.