This is and indirect app sheet question, regarding google sheets.
I am trying to create an arrayformula in sheets that will look at a related “key id” column and gather all text from another column from all rows with the same related “key id”:
– col A / col B / col C
1- KEY ID / NOTE / COMPILED NOTES
2- A1BZ / TACO / TACO FROG
3- T212 / CORN / CORN APPLE
4- T212 / APPLE / CORN APPLE
5- CD41 / DOG / DOG
6- A1BZ / FROG / TACO FROG
(Ignore the fact that rows cannot share a KEY ID, I know this. It’s just simplified to display the idea).
I am using it as a back end formula and as the sheet is active (having rows removed and added I need this to be an arrayformula. I thought some type of JOIN() with an IF statement. But I’ve note come up with anything that works. I can make it work if it’s not an array formula with a FILTER(), but the formula doesn’t always auto propagate into new rows.
I understand that there are ways to do this directly in Appsheet, but the issue is in keeping the data “live” with out having to “update” each affected row. Again I understand I could create an action to do this, but the back end sheet solution seemed the simplest.
Any thoughts from the hive mind?
Solved! Go to Solution.
On a related note the “arrayformula” for the google sheets side would look like this for my demo example above.
=ArrayFormula({“COMPILED NOTES”; IF(A2:A="",VLOOKUP(A2:A,TRIM(SPLIT(FLATTEN(QUERY(QUERY({A2:A&"~",B2:B},“Select MAX(Col2) WHERE Col2 Is Not Null GROUP BY Col2 PIVOT Col1”),9^9)),"~")),2,FALSE))})
And the fully functional table side of google sheets the final product looks like this:
=ArrayFormula({“COMPILED NOTES”; IF(I2:I="", VLOOKUP(I2:I,TRIM(SPLIT(FLATTEN(QUERY(QUERY({I2:I&"~",N2:N},“Select MAX(Col2) WHERE Col2 Is Not Null GROUP BY Col2 PIVOT Col1”),9^9)),"~")),2,FALSE))})
Dont user Spreadsheet formula, but user AppSheet expression to achieve your goal (app).
There are 1000’s of rows and 10’s of “related key id’s”. I would need a way in the app that anytime a record is added / updated / or deleted, that it searches for all related “related key id’s” and updates those entries at the same time. Seems a cumbersome way to go about it when an arrayformula will do the same in less time.
Appsheet is not supporting arrayformula as far as I know.
You are correct, Appsheet doesn’t support arrayformulas. Google sheets does, I uses them across 13 different apps to help do things that Appsheet isn’t very good at.
Appsheet can do the same
My point is don’t lean on spreadsheet formula but use Appsheet expression to achieve your goal
Select(TableName[Col B],[Key ID]=[_ThisRow].[Key ID])
Works great for a single row, but not if I need to update 10 or 20 rows that have the same data.
This would work as a virtual column. So everytime to add or update [Col B] then [Col C] will recalculate.
I will give the virtual column a shot.
Disclaimer, I don’t really recommend doing this, but if you must know…
FILTER and QUERY don’t really work inside arrayformula. VLOOKUP does though, but only returns a single value, so you’ll need 1 formula per column.
ARRAYFORMULA( IF( key-cell-range <> "" , VLOOKUP(...) , "" ) )
Load the table into the app without the formula, then put the formula in afterwards so Appsheet doesn’t even know about it.
Thanks for the assistance. I have used many backend formulas (and arrayformulas) before and they work great with appsheet. The array vlookup will not work due to the single value return.
Right, so what’s wrong with my suggestion
?
Seems like I will need to create an action that search’s all data entries with “related key id’s” and update them as well.
You could evaluate AppSheet’s Webhhok API option to collate the text based on changes in [Note] column. Testing over 4 /5 records collation shows that the update is fairly quick. But if the change traffic of records changing or getting added is high, it may not be practical and even not advisable either way - with actions or webhook
The example below shows when the [Quantity] is added through “Order Details” in an order, the Webhook runs to update all the records for that order ID with cumulative quantities for all the order detail records. ( In the example the order ID is “304C5A83” and quantities of 5 and 10 were added through different order details that were collated in the [ProductQuantity] column.
I will give this a look, seems pretty promising.
On a related note the “arrayformula” for the google sheets side would look like this for my demo example above.
=ArrayFormula({“COMPILED NOTES”; IF(A2:A="",VLOOKUP(A2:A,TRIM(SPLIT(FLATTEN(QUERY(QUERY({A2:A&"~",B2:B},“Select MAX(Col2) WHERE Col2 Is Not Null GROUP BY Col2 PIVOT Col1”),9^9)),"~")),2,FALSE))})
And the fully functional table side of google sheets the final product looks like this:
=ArrayFormula({“COMPILED NOTES”; IF(I2:I="", VLOOKUP(I2:I,TRIM(SPLIT(FLATTEN(QUERY(QUERY({I2:I&"~",N2:N},“Select MAX(Col2) WHERE Col2 Is Not Null GROUP BY Col2 PIVOT Col1”),9^9)),"~")),2,FALSE))})
Thank you very much for sharing the array formula and solution. The formula is indeed impressive and extensive.
Just so that we understand the requirement better for any future use, may we request you if possible to share the approximate volume of record changes in a single day (Adds of new records plus edits of the [Note] column that needs collation).
You question is not an easy one to answer. In short anywhere from 1 to 1000 additions, changes or deletes in a day. I am happy to provide more details for you & the team to help you understand.
It is part of a rather complicated / interlinked, Tracking number generator, Calendar, and timesheet system (and other apps). This formula is being used in the Calendar system (table based not google calendar). Which in itself (on the surface) may only have 10 to 50 additions / changes / deletes per day to the Calendar.
Here’s a very very basic breakdown of the system (I will try to be concise).
Tracking numbers (New entries per day 1 - 200) This is the systems core, everything uses this.
Time Log (New entries 10 - 100 per day)
Calendar (New entries 10 - 50 per day)
The system is rather large (12 apps working together as one). The technician Calendar app references only the Calendar table as read only to keep the speeds up. So the data cannot be referenced via Virtual Columns on the technician app. It can be referenced in the managers calendar app, but then needs to be written to a physical column so it will appear in the technician app. As soon as you write data in Appsheet you need to update each individual instance of the data to update if the virtual data changes so it writes correctly so the technician calendar displays correctly. I know there are ways to do this but they all involve someone doing something in the app. The google sheet side arrayformula takes care of this with out the need to update anything. We then always know that the calendar data across all of the technicians calendar entries is up to date.
I use many google sheet side arrayformulas across all of the apps to facilitate automatic updates like the calendar note update. For example the Correctives table has one that looks at the Estimates and the Time Logs to see if estimates have been created or if the corrective has been done (estimates has a similar formula to see if a project has been completed). I also use an arrayformula to create (problem free) sequential tracking numbers, as Key ID’s are confusing for our technicians. Key ID’s are still there, the technicians just don’t use them to communicate. It’s simple to say that you are working on Job 3520, and search that number over the entire system, or remember it to enter it into your time log, rather than 6029e56b.
I hope I have given enough detail, but not too much to be confusing.
Hi @Tom_Stevens ,
Thank you very much for such a detailed explanation. My question was of course just to know the volume of updates to your original requirement so the future reader of the post and us could probably understand when it makes sense to use say actions/ webhook options versus arrayformulas option.
Your operation seems substantial for calendar (10-50 entries per day). I was wondering if webhook option would also have helped in this case. But you seem to need instant updates in many places, in many apps, so arrayformulas make sense.
Thank you again very much. Appreciate.
User | Count |
---|---|
17 | |
14 | |
10 | |
7 | |
4 |