Hereās how I would do itā¦
To make things simpler, I would load the first and last items into two groups first (used as variables, just to hold those items for reference later), and then simply deduct the value of the smaller number form the higher one.
So, add two groups somewhere to your page (it can be in a hidden popup, and/or it can have 0 height and width so it doesnāt take up any space on your page).
Set the content type of both groups to be āDevice Valueā.
In one of the groups, lets call it āGroup Min Valueā, load the first āDevice Valueā entry of the month, by searching for Device Values, within the given month, sorting by the Date field (descending: No), and selecting the first item.
Then do the same for the other group, letās call it āGroup Max Valueā, but this time loading the last Device Value of the month (sort by Date descending Yes and select the first item).
Then all you have to do is, wherever it is you need to do it, subtract the lower Device Valueās Value from the higher one by referring to Group Max's Value's Device Value's Value - Group Min's Value's Device Value's Value
(of course, you donāt have to use two groups to hold the data⦠you could just do those searches directly in your final expression, but it makes thing simpler to manage and edit, and means you only have to do it in one place, even if you need to refer to them in multiple places on your page).