# Script apply formula to sheets when née cell data is added

**URL:** <https://community.glideapps.com/t/script-apply-formula-to-sheets-when-nee-cell-data-is-added/34802>\
**Category:** Ask for Help\
**Created:** [November 20, 2021, 5:17am UTC](https://community.glideapps.com/t/script-apply-formula-to-sheets-when-nee-cell-data-is-added/34802 "2021-11-20T05:17:12Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![jturbo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jturbo/32/34852_2.png) [@jturbo](https://community.glideapps.com/u/jturbo)\
**Post date:** [November 20, 2021, 5:17am UTC](https://community.glideapps.com/t/script-apply-formula-to-sheets-when-nee-cell-data-is-added/34802/1 "2021-11-20T05:17:12Z")

</div>

Trying to find a way to add a working formula to a cell as the data gets added in.

I can add the formula to all the cells in the column however it creates a “0” and app will display erroneous data as a result.

I think a script could handle it however I’m doing my best to learn glide and sheets on top of that.

Thanks for any direction to learn more about it.

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [November 20, 2021, 5:23am UTC](https://community.glideapps.com/t/script-apply-formula-to-sheets-when-nee-cell-data-is-added/34802/2 "2021-11-20T05:23:12Z")

</div>

A direct answer to your question is to use an arrayformula.  
But… do you actually need the result of the formula in the Google Sheet, or will it just be used in your app?  
If you don’t need it in the sheet, then you are much better off performing the calculation in Glide using computed columns.

---

<div class="post-metadata">

**Author:** ![jturbo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jturbo/32/34852_2.png) [@jturbo](https://community.glideapps.com/u/jturbo)\
**Post date:** [November 20, 2021, 1:50pm UTC](https://community.glideapps.com/t/script-apply-formula-to-sheets-when-nee-cell-data-is-added/34802/3 "2021-11-20T13:50:04Z")

</div>

Thanks for that. So make the calculation on the app versus the spreadsheet?

I’ll have to play around with it to try and make it work. But sounds like transpose the calculation and display the result.

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [November 20, 2021, 1:52pm UTC](https://community.glideapps.com/t/script-apply-formula-to-sheets-when-nee-cell-data-is-added/34802/4 "2021-11-20T13:52:49Z")

</div>

Yes, do the calculations using Glide computed columns. If you need some help with that, just ask.

---

<div class="post-metadata">

**Author:** ![jturbo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jturbo/32/34852_2.png) [@jturbo](https://community.glideapps.com/u/jturbo)\
**Post date:** [November 22, 2021, 3:55pm UTC](https://community.glideapps.com/t/script-apply-formula-to-sheets-when-nee-cell-data-is-added/34802/5 "2021-11-22T15:55:58Z")

</div>

Thanks Darren…here is what I have.

=SUMIFS(Priorities!D:D,Priorities!E:E,A2,Priorities!A:A,B2)

This is what the Sheets formula looks like…i didn’t create it. I think it’s a simple addition of results on othe tables.

Just picking this up so I am still struggling to make sense of the “How to do it”

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [November 22, 2021, 4:15pm UTC](https://community.glideapps.com/t/script-apply-formula-to-sheets-when-nee-cell-data-is-added/34802/6 "2021-11-22T16:15:13Z")

</div>

Could you provide a screenshot of the associated Google Sheet, that shows the column headings for columns A through E?

---

<div class="post-metadata">

**Author:** ![jturbo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jturbo/32/34852_2.png) [@jturbo](https://community.glideapps.com/u/jturbo)\
**Post date:** [November 22, 2021, 4:30pm UTC](https://community.glideapps.com/t/script-apply-formula-to-sheets-when-nee-cell-data-is-added/34802/7 "2021-11-22T16:30:25Z")

</div>

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/f/2/f23246bcba2d8d2451337cd9ead0576d8f5cf949.png)

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/4/b/4ba66f1fe43c4b2349180d5a9f0bb4d7328cca3f.png)

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/0/c/0c75110028ac0dd47908a7de3f72e37f88a82649.png)

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/f/b/fbd0702c462e129be7ab4235c141cf9187b151af.png)

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [November 22, 2021, 4:46pm UTC](https://community.glideapps.com/t/script-apply-formula-to-sheets-when-nee-cell-data-is-added/34802/8 "2021-11-22T16:46:07Z")

</div>

You should be able to create a template column in both the Weeks table and the Priorities table that joins the Creator column value to the Week Name column value. Then create a relation column that links the template in the Weeks table to the template in the Priorities table. Finally create a Rollup column that uses the relation to sum the matching values from the Priority Minutes column.

---

<div class="post-metadata">

**Author:** ![jturbo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jturbo/32/34852_2.png) [@jturbo](https://community.glideapps.com/u/jturbo)\
**Post date:** [November 23, 2021, 4:23pm UTC](https://community.glideapps.com/t/script-apply-formula-to-sheets-when-nee-cell-data-is-added/34802/9 "2021-11-23T16:23:32Z")

</div>

Thanks @Jeff_Hager. I think i need to adjust this a bit, because I am getting a total count of unique week names.

I think I still have a gap between what i have and what I am hopoing to create.

---

<div class="post-metadata">

**Author:** ![Eric\_Penn](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/eric_penn/32/73888_2.png) [@Eric\_Penn](https://community.glideapps.com/u/Eric_Penn)\
**Post date:** [November 23, 2021, 4:26pm UTC](https://community.glideapps.com/t/script-apply-formula-to-sheets-when-nee-cell-data-is-added/34802/10 "2021-11-23T16:26:21Z")

</div>

Probably in your rollup column you should switch the operation from count to sum.

---

<div class="post-metadata">

**Author:** ![jturbo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jturbo/32/34852_2.png) [@jturbo](https://community.glideapps.com/u/jturbo)\
**Post date:** [November 23, 2021, 4:29pm UTC](https://community.glideapps.com/t/script-apply-formula-to-sheets-when-nee-cell-data-is-added/34802/11 "2021-11-23T16:29:31Z")

</div>

@Eric_Penn …that is insane you knew that…looks like a winner!
