So this is potentially not possible to do with a data expression but I really do not know as this seems to be quite a complex calculation.
Consider the following table of daily sandbag counts. We are trying to dynamically count the Sandbags Taken figure based on data collected using a Survey123 count. There are 5 depots. I have been able to create a data expression that reports the latest count by depot and can use the Sum statistic on a gauge indicator to get the total current count. I am assuming that if I had the Sandbags Taken figure for each depot, I could do the same and get the grand total.
This next bit requires calculating totals for the last two dates (counts are not always daily and could be weeks apart hence needing Max(Date) and Max(Date)-1 or similar) and subtracting the total counts to calculate how many have been taken. For a bonus bit of difficulty, ideally we include the daily production figure (but currently this is in a different dataset to add a bit of complexity).
I would appreciate any thoughts on this, table below for (hopefully) some clarity.
The other alternative approach could be with Python to populate fields in the feature layer itself if a Data Expression is not going to cut it.
thanks in advance,
Len
DateOfCount | Depot | Count | Taken (calculated) | Produced |
1/11/2022 | A | 100 | | |
2/11/2022 | A | 50 | 50 (count Date1 – countDate2) | 150 |
3/11/2022 | A | 150 | 50 (CountDate2+ProductionDate1-CountDate3) | |
| B | | | |
| B | | | |
| B | | | |