Questions folks
I got a formula Iโm using to get the number of days between a date in the current row from the date in the preceding row
HOUR(MAX(SELECT(The Feed_Raw[Date], [_THISROW].[_RowNumber] > ([_RowNumber]-1))) - MAX(SELECT(The Feed_Raw[Date], [_THISROW].[_RowNumber] > [_RowNumber]))) / 24
Works fine, but itโs adding 2-3 minutes of sync time (the data set has about 2600 rows). It feels clunky to me
Any ideas to make this equation simpler to cut down sync time? (I need to access all the rows, so Iโm not interested in solutions to slice the data sheet)
Appreciate any help
[_THISROW] is from which datasource? More importantly, is it from โThe Feed_Rawโ datasource or some other?
If you mean what table itโs referring to, it is โThe Feed_Rawโ @WillowMobileSystems
Yes, I as trying to be more general by using the term datasource since we have tables and slices.
I have an idea. Iโm trying it out now and will get back in a few.
My idea is not panning out. I thought I could force a reference to the previous row by RowNumber without using a select. Either itโs not possible or Iโm just not seeing how to do it.
Iโm wondering, if the calculation can be performed in a different way?
The dates - are they representing entry dates of the records? If not, what do they represent?
Also, is the result of the calculation stored in an actual column or is it a Virtual Column?
I hope thereโs a simpler answer, this calculation prevents me from designing the app as i want.
Re: dates. The simple answer is yes.
But the actual answer is that we use the app to record when we publish photos. If we add the record to Appsheet when we publish a photo (as weโre supposed to) then this answer suffices. But we may enter the record the day after, so weโll need to edit the date. So a timestamp wouldnโt work in this case.
The data is stored virtually. Iโm trying to get away from extraneous columns in my spreadsheet so the app will run faster. So i would like to avoid empty columns for appsheet to enter data. @WillowMobileSystems
Ok, for full understanding then, when you enter the record โlaterโ, which means its not in order, and edit the date, how do you know which other record you want to calculate the number of days from?
I understand what you are saying about extraneous columns. However, Virtual Columns, because of the fact they donโt store results, re-calculate each time a sync is performed. Your expression is performing TWO selects on EACH and EVERY row each time a sync is run. This is slowing the sync tremendously!!
But if you think about it, the Days value only needs to be re-calculated if the Date its based on changes.
If you were to simply make the Days column an actual column and then place your expression in that columns App Formula, you would see a significant improvement, 10-fold+, in the sync time.
I do also want to caution about the usage of RowNumber in your calculations.
It is not a stored value with the row, it is assigned as rows are loaded into AppSheet. Iโm not sure how AppSheet loads rows, but typically we should never expect that rows are always loaded in the same order. If that is true, then the RowNumber value may not always be the same for a particular row in the data. In fact, AppSheetโs documentation strongly recommends against using RowNumber and I think it is for this very reason.
This is why I am asking the question at the top of this post. If it can be identified how to perform the calc without depending on row orderโฆand implement the suggested column changeโฆthen youโll be golden!!
@WillowMobileSystems a bit confused by your question. but to best explain.
We โshouldโ be entering the data in the app in the same order that it is published. The value I wish to get tells me how many days have pass between the last time we posted. If we enter the information chronically as weโre supposed to, then the info Iโm looking for will naturally be revealed. If we do not, then we need a simple way to reorganize in our app.
All go my views are organized by the row number. I couldnโt strictly use dates because sometimes we publish twice a day. This is why I relied on the row number. I couldnโt calculate the row number with a sheet formula because if someone entered info in the wrong order, I cant change it in the app.
Iโll figure out a different idea then the row formula. But you reply brings me to a question that is beginning to frustrate me with developing on Appsheet.
As of the moment, my data source contains many columns of metrics that have been imported from another sheet that does their calculations. So my data source is essentially a โflatโ file, with no formulas. (I have Delta Sync turned on) It takes about 30 seconds to sync, which is about 15secs longer than I expect
However, I was told by one of the Appsheet mods that my app would perform faster with virtual columns for the formulas, since the app would be syncing less columns.
I my questions is, what is faster?
Synching flat-files with many columns?
Or using virtual columns with app formulas?
Or using actual columns with app formulas?
That answer will help determine what I should structure my data source
as an addendum,
the reason why I suspicious of adding more columns with values is because of the 30-second sync, even if Iโm only adding a new row.
I donโt know if Appsheet is counting the imported values on the backend as a โchangeโ and just re-synching all the rows anyway.
Right. While I am answering your questions above, I encourage you to use the Sync Analyzer in AppSheet. Youโll find it in the bottom right-hand corner of the emulator. It will tell you where the majority of your sync time is focused.
First, I understand your frustration.
I do want to point out that the decision to calculate or store the values is NOT isolated to AppSheet. I have been a professional software developer for over 25+ years and every development platform has this problem.
Unfortunately your questions cannot be answered in a general sense because it depends on what kind of calculations that are being performed, how the results need to be used and your primary goals in the app - fast response, flexibility, small app size, etc
Depending on what your implementing, you may need to make trade-offs to achieve the goal. Trade-offs could be achieved in many ways.
For example, if it was a set of a dozen calculations based on other values in the SAME row. Absolutely, I would use Virtual Columns and not store them in the sheet.
However, if I needed those same 12 calculations to show in a report, then I would need to store them to be used later.
In your case, the Virtual Column needs to search the entire table TWICE to find the two rows it needs to perform the calculation. As the table grows, so does the time it takes to perform those two searches.
So, to compromise and improve user experience, you would want to store this particular value.
If you donโt need the value to dynamically recompute and are satisfied with it updating only when the row is updated, create a normal (not virtual) column to hold the computed value. That computed value will then have no significant effect on sync time.
ok, noted. thanks guys @Steve @WillowMobileSystems. I guess I should avoid virtual columns
So hereโs my last 2 question about this.
As I mentioned before, I have calculations in my sheet imported hourly from another spreadsheet (Iโm using Google Appscript).
Do either of you know if Appsheet determines the imported values are a โchangeโ even if the value is the same?.
Iโm still perplexed why the sync takes as long as it does, even though only one row is changingโฆ
I believe a change is a different value sent from an app to the AppSheet server. I donโt believe workflows (for instance) will notice a data source change that doesnโt originate within the AppSheet framework. Specifically, I donโt think AppSheet would see the changes resulting from your hourly import as โchangesโ.
I donโt know. Should be easy to test.
If the data is computed elsewhere and is static within the AppSheet scope, I see no reason for AppSheet to compute it.
@Mic_L_Angelo First, I wouldnโt say you need to avoid Virtual Columns. They have tremendous value and when to use them or a โnormalโ column is not straight forwardโฆit will depend on your needs. Experience will be your best teacher but if you are ever uncertain just ask here in the Community.
To strengthen what @Steve has said.
AppSheet does NOT react to changes made to the sheet from other input sources. What AppSheet does do is track changes made within the app. Those changes will be posted to the sheet, AppSheet will wait for any formulas to complete and then will re-sync the data between the sheet and the app. ANY changes by AppSheet or otherwise will be pulled into the app by the Sync.
User | Count |
---|---|
19 | |
13 | |
8 | |
3 | |
2 |