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 |
---|---|
18 | |
14 | |
11 | |
7 | |
4 |