Streamline repetitive long formula calculation in google sheets

58 views
Skip to first unread message

Joyce Brown

unread,
Mar 1, 2021, 4:59:53 PM3/1/21
to Google Apps Script Community

Summary tab contains project name which is the name for remaining tab names in my google sheets as follows:

TabName
Project1
Project2
Project3

There may be up to 20 TabName rows defined but this is not necessary. All project name tabs have the same format - Row 1 contains the weekly start dates and Column 1 has the resource names. The following is what the project name tabs would look like -


Project1 tab

Person1-Mar-20218-Mar-202115-Mar-202122-Mar-202129-Mar-20215-Apr-2021
John224555
Jane1111
Abe55


Project2 begins at a different Start Week from Project1 and Project3.


Project2 tab

Person4-Jan-202111-Jan-202118-Jan-202125-Jan-20211-Feb-20218-Feb-202115-Feb-2021
Joe224555
Mary1111
Abe55


Project3 begins at a different Start Week from Project1 and Project2.


Project3 tab

Person8-Feb-202115-Feb-202122-Feb-20211-Mar-20218-Mar-202115-Mar-202122-Mar-202129-Mar-2021
Joe224555
Mary1111
John55
Marg333


Note, not all resources are across all projects (e.g. Jane and Marg are only in one project).


In the summary tab, it should show the concatenation of all projects by resource and week as follows -


Resource Weekly tab

Person4-Jan-202111-Jan-202118-Jan-202125-Jan-20211-Feb-20218-Feb-202115-Feb-202122-Feb-20211-Mar-20218-Mar-202115-Mar-202122-Mar-202129-Mar-20215-Apr-2021
JohnProject3 (5)Project1 (2)Project1 (2) Project3 (5)Project1 (4)Project1 (5)Project1 (5)Project1 (5)
JaneProject1 (1)Project1 (1)Project1 (1)
JoeProject2 (2)Project2 (2)Project2 (4)Project2 (5)Project2 (5)Project2 (5) Project3 (2)Project3 (2)Project3 (4)Project3 (5)Project3 (5)Project3 (5)Project3 (5)
AbeProject2 (5)Project2 (5)Project1 (5)Project1 (5)
MaryProject2 (1)Project2 (1)Project2 (1)Project2 (1)Project3 (1)Project3 (1)Project3 (1)Project3 (1)
MargProject3 (3)Project3 (3)Project3 (3)


Column 1, which contains the resource name and Row 1 with the start dates are fixed (i.e. no calculation required). Also, where a resource has more than one projects, the concatenated projects are separated by a line return.


The concatenation calculation should ideally not perform if the Start Week does not have a date OR if there is no resource name defined for that row. The Summary tab will identify the number of project tabs that exists where the concatenation calculation needs to look for data.


I do have the Resource Weekly tab working using a very long SUMPRODUCT and INDIRECT. However, the google sheet is now running much at least 5 times slower when I added this Resource Weekly sheet.


Is there a way to do this using app script?

cbmserv...@gmail.com

unread,
Mar 1, 2021, 9:05:51 PM3/1/21
to google-apps-sc...@googlegroups.com

Hi Joyce,

 

You can make Apps-Script do pretty much anything. I don’t see why it would not be able to run your spreadsheet for you.

 

However, you did not explain which tab is a view only and which one is used to input info.

 

Typically Apps-Script would run more efficiently if calculations and updates done are done on a trigger of some type. Like a data entry.  Have you considered using a Form to enter the data to make it less error prone?

 

Thanks.


The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/ca9394dd-eaf4-4995-8553-c559ab5ffebco%40googlegroups.com.

Joyce Brown

unread,
Mar 2, 2021, 12:11:59 AM3/2/21
to Google Apps Script Community
Hi George,

The link, https://docs.google.com/spreadsheets/d/1giInVlEcmr1CeABqa1mM8HTrjtYy0LFPbvpHCNdus1w/edit#gid=0, is the file along with the SUMPRODUCT and INDIRECT formula contained in the Weekly tab. This is a much shorter and simpler version of the actual formula. For example, the project files would contain an additional column that denotes Y for remote work and null if it is onsite. I would separate this as 2 separate lines with a notation at the beginning. For example if Joe on Feb 8 working on Project2, if his 5 days on Project 2 was 3 days remote and 2 days onsite, the expected result would be Project2 (2) new line R Project2 (3) new line Project3 (2).

The expected results can be seen in the Weekly tab with the formula calculation. I would like to convert this repetitive formula to an app script so that my spreadsheet runs faster. It is at least 20 times slower than it used to be ie. a sec and now 20 to 30 secs

I would like the Weekly to refresh when there is a change in the Project tabs.

Thoughts?

jb

To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-community+unsub...@googlegroups.com.

CBMServices Web

unread,
Mar 2, 2021, 3:33:03 AM3/2/21
to google-apps-sc...@googlegroups.com
Hi Joyce,

 I think I understand. So basically any changes in the project tabs, you want them reflected in the weekly tab.

But not sure I understand how you want the remote work to be displayed in the weekly tab or the project tabs. Can you make a change to the spreadsheet to show how it should appear?

 Thanks

To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.

The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/016ed69f-a282-4a09-8364-07d16316ec06o%40googlegroups.com.

CBMServices Web

unread,
Mar 2, 2021, 1:50:28 PM3/2/21
to google-apps-sc...@googlegroups.com
Hi Joyce,

 What I would suggest is just adding an onEdit function to update the summary tab. Any changes done to the project tabs would automatically be reflected in the summary tab in this case. I would think this function would run pretty fast and will make the spreadsheet self updating.

 Here is what I would put in the onEdit function:

function onEdit(e) {
  // find if sheet being changed is a project (or Summary tab) exist on Summary
  // get date field (top row, same column)
  // get resource name (same row, first column)
  // find resource name in summary sheet else addline for resource and sort
  // find column in summary sheet with correct date field if not, add column at end of sheet
  // update field for that date with resource usage

}

I see that someone has started some code in the spreadsheet already, and they seem to have a good understanding of Apps-Script. But if you need more help putting this together, let me know.

Thanks,
George
Reply all
Reply to author
Forward
0 new messages