Pulling previous number entry from database for calculations by location

First time posting -
I am trying to do a simple calculation and I can’t seem to figure out a workaround.

Application: we do machine visits every couple weeks, every 2 weeks we input numbers from a mechanical coin counter. I am trying to get the count from the previous visit to subtract it from the current count (i.e. todays count = 1200, last weeks count = 1000, I want it to display 200).

If I only had one machine I believe I could get this working by pulling max number from database - but the calculation pulls max number from highest reporting machine instead.

Is there a way to do this?
I was reading some stuff about post IDs maybe being the key to solving this but that isn’t a feature yet.

Thank you!!

Screen Shot 2023-04-30 at 3.30.12 PM

Hi @motiongfx ,


Just an idea, why don’t you have machine collection and relate that to counter collection, so that whenever you pull the last counter, it is based on machine.

All collections are linked currently but I wasn’t able to pull the last machine collection number - it was only giving me options of sum, Average, Minimum, Maximum…

So I attempted to used Maximum (the highest last # in the database was my thought process), but it was pulling the highest number in the machine collection…and that wasn’t necessarily always the right machine association.

You make it sound easy, and it probably is…but I’m at a loss

At the collection level, choose machine first then counter, so it is that nested menu that you choose.