Dynamically populate a filed in google apps script

I have a sheet called "Base Sheet" in following format

 Order#    Weight
 1213      345
 1213      567
 3450      111
 3450      222
 3451      444

I group by based on "Order #" and sum "Weight" and populate in a sheet called "Weight"

Order#    Total_Weight    Deleted_Status
1213       912
3450       333
3451       444

I do the grouping and summing using "ALASQL" library.

var res_1 = alasql('SELECT [0] as Order#, sum([1]) as Total_Weight FROM ? GROUP BY [0]',[row]);

My challenge is if an "Order#" is completely deleted from "Base Sheet" then the corresponding "Order#" in the "Weight" sheet should have the "Deleted_Status" as "Yes".

Let's say we delete Order# "3451" from Base sheet, then in "Weight" sheet it has to be

Order#    Total_Weight    Deleted_Status
1213       912
3450       333
3451       444            Yes

Not sure how to implement this logic in Google Apps Script dynamically. Any suggestions would be appreciated.



Read more here: https://stackoverflow.com/questions/67378093/dynamically-populate-a-filed-in-google-apps-script

Content Attribution

This content was originally published by user3447653 at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: