I’m working on an app where adjusting one value changes the number of records to be displayed in a slice. Apparently, slices are repopulated immediately, which is good. However, I would also like the count of that slice to be display immediately – and, of course, accurately. I tried a number of methods to get the count of the new slice using virtual columns but the correct count was only displayed after the sync had been completed – at least several seconds later. Worse yet, an incorrect count, based on previous data would be displayed until AppSheet finally allowed the virtual column to make the correct calculation.
Well, after a lot of trial and error (mostly error ), I finally found a way to force AppSheet to display the new count immediately, without waiting for the sync:
Make an action that writes the new count (or whatever value you want) to your spreadsheet. Then, if you configure your app so as to display the content of that cell, it will reflect the new value immediately, even before the sync is complete.
Of course, writing to the spreadsheet takes time. Ironically, however, it seems that putting the expression in an action and telling AppSheet to write it to the spreadsheet tells the platform to prioritize the calculation.
This trick isn’t practical if you need to recalculate the value frequently. In my case, however, users will only wind up invoking this action occasionally, so I can live with it. The sync itself will occur in the background but the user will see the correct count immediately.