Would like blank cells to show value of adjacent cell - google-apps-script

I made a budgeting spreadsheet and have a "current" and "ideal" column. Current is what I'm spending now. Ideal is what I'd like to be spending. In some cases the "ideal" number is the same as "current."
What I would like to do is put in "ideal" values where necessary and otherwise just give the value of the "current" cell.
For example:
Expense
Current
Ideal
Rent
3000
Vacation
1000
5000
I don't plan to move so my rent would, ideally, still be 3000. But I'd like to spend more on vacation. So what I'd want is a formula for the ideal row that would show the value of the adjacent cell if the ideal cell is blank. I suppose it would be something like this:
if (isblank(this_cell), offset(this_cell, 0, -1))
So far I can't even find a way to reference the current cell at all - I found suggestions but they all gave me a circular reference error. And I don't know if offset is the best function but I've been googling around and it seems like a possibility.
Can this be done, and if so, how?

Related

Weighted Grades by Category, Multiple Students/Cats

Looking for a way to track students grades in sheets and have their overall grades calculate depending on scores for each assignment/category.
So all assignments are 40% of the overall grade, Assessments- 40%, and Progress- 20%.
My thinking is that a script would make this much more useful and easier than a massive ifs formula.
Attached is a sample of what/how it would be set up...
sample of sheet
Thank you in advance.
So google sheets does have a AVERAGE.WEIGHTED formula which should make it possible for you to do what you want, hopefully. It also appears like you have set up data validation for the assignment type drop down menu and have the appropriate points displaying on the row above. (If you have not done this, then it is possible for the Pts header to be automatically updated based on your grade scale using a VLOOKUP).
Determining the weighted average should only require adding formulas to the "Overall Grade" column. Below is a formula you can use that should work for you:
=AVERAGE.WEIGHTED(D5:F5,$D$2:$F$2)
Basically, it takes the row of assignments (row 5 in my example) and compares it to a corresponding locked list where the weights appear in row 2. You will need to modify the array slightly for your purposes just so its long enough to reach as far as your row of data. This can be done by changing "F" in the formula example to be the farthest column of data. This formula can be drag-and-dropped as far down as you like on the overall grade column. It will display results like this:
EDIT:
To take into account maximum points allowed per unique assignment requires a little bit more set up but is still very doable. Basically, we can do the same thing as before but before we average the values we need to determine the values in consistent scale. For example, if a student makes an 15 on an assignment with a max points allowed of 15, they make 100%. Likewise if they make a 2.5 on an assignment with a max point allowed of 5 then they make a 50%.
We can determine this by taking the points earned / max points * 100. We need to determine these new values before applying the weights.
To make things much easier, it would be best to add a new header which provides the corresponding max points for the selected assignments. Again, this can be added to the legend and then referenced using a VLOOKUP with exact match. So something like this (if you don't like the max points row showing you can even hide the row):
Once this information is added, we will have an easier time referencing the max value per student entry. We can calculate the 100% grade scale automatically for the row with an =ARRAYFORMULA insertion. The same formula we used earlier to find the weighted average can be modified to the following:
=AVERAGE.WEIGHTED(ARRAYFORMULA(D5:F5/$D$3:$F$3*100),$D$2:$F$2)
With this new formula the new "Overall Grade" column will take into account both the grade weights as well as the max points allowed for each assignment type on a 100% point scale.

Scan COLUMN for key set of initials, get value of that ROW, then get CONTENTS of different CELLS

I have access to a review sheet, regarding the review of web content articles for blogs. I'm one of the reviewers.
Here's an image of the review sheet (I'm sorry, I haven't been granted access to embed images):
EXAMPLE REVIEW SHEET
I want to produce in invoice based on that review sheet. Here's the invoice:
EXAMPLE INVOICE
I understand how to create the link between the two separate spreadsheets, but what I need is this:
In the EXAMPLE REVIEW SHEET I need to look down COLUMN B (INITIALS) for the last instance only of initials 'MF' and make a note of the ROW
Then, I need to scan back up COLUMN B, for 3 more instances of MF, and make a note of the ROWS for all 3 instances.
I now have the last four instances of MF, and the ROWS they appear.
Now in my EXAMPLE INVOICE, I want to populate cells B19-22 with the contents of cells Aw Ax Ay and Az from the EXAMPLE REVIEW SHEET, where w, x, y and z are the 4 ROW NUMBERS that we got from the original LOOKUP.
Here's the link to the actual sheets (all on one spreadsheet for the examples)
ACTUAL SHEETS
For some other invoicing requirements, I found this line of code:
=index(B:B,max(row(B:B)*(B:B<>"")))
Which I know returns the lowest-positioned non-empty cell in a column. But I don't really understand WHY it returns it, I just know that it does. I'm sure some part of the INDEX function can help to return the values I need, but I don't know how.
I'm guessing that what I'm looking for is beyond the fx input on the spreadsheet, and requires a script to be run. Whereas I can sometimes make sense of some basic programming - and by that I mean ANSI 74 BASIC, which is where my knowledge stops - I can't really program using the script editor.
What I'd LOVE is if someone could help me, and also explain the logic behind the solution. I'll probably need it in layman's terms, but I'd really like to start understanding how to manipulate spreadsheets - so I'm really keen to find out HOW something like the INDEX code works, and what the variables mean.
I've tried to fathom the explanations given by Google but, TBH, their way of explaining seems to require that you understand their solution before they explain it to you. The examples are very hard to relate to the formulae, because the description of the variables is not 'human' enough.
If anyone fancies a stab at my problem, and could take the time to explain the logic behind the solution, please know that I'll be forever thankful!
Regards,
Miles
I think this formula will work for you, but unfortunately it's a bit more sophisticated than would make it easy to understand. I placed it in P19 on the Invoice tab.
There are a few different ways to solve your problem, but i wouldn't use INDEX() for any of them.
=ARRAYFORMULA(QUERY({'EXAMPLE REVIEW SHEET'!A2:B,ROW('EXAMPLE REVIEW SHEET'!A2:B)},"select Col1 where Col2='MF' order by Col3 limit 4"))
If you were willing to have a numbering column to the left of the table in the "Review Sheet" it would make all of this much simpler and I could show you how to do it in a way that might make a bit more sense.
Thanks for answering so quickly!
The REVIEW SHEET is maintained by somebody else, but I have editing rights as I need to fill in my review comments. I was planning to keep a linked copy of REVIEW SHEET as a tab in my Work Spreadsheet. If I do this, then there's no problem with adding a numbering column, or any extra columns that you think will help.
Thanks again
Miles

How can I reduce google sheets lag by replacing thousands of cell by cell formula calculations with an elegant script?

first time posting, so bear with me.
I have successfully designed a google sheet that automatically creates a crop map based on the crop plan in another tab ('Successions')
In 'Successions' the following columns are relevant:
Column A - Succession ID
Column C - Row ID
Column R - Planting Date
Column W - Harvest Date
In "Map 1A" I have created a map of our field, with Column B representing the Row ID and the columns to the right each representing a week of the year, whose start dates are defined in row 2.
My goal is to map each succession on the appropriate row for the duration that it will be in the ground (Planting Date to Harvest Date). I will have different successions occupying the same row during different date ranges.
I accomplished this in three steps:
Step 1
Every cell (except the left most column) contains a formula that returns and text joins (if multiple results) any successions in that row during that week - if an only if the value it would return is different than the value the cell to left would return. The result is that the succession ID is only displayed on the week that it starts. The formula in these cells is:
=Iferror(If((Textjoin(" / ",True,FILTER(Successions!$A$2:$A$647,RegExMatch(Successions!$C$2:$C$647,$B3),Successions!$R$2:$R$647<D$2,Successions!$W$2:$W$647>D$2)))=(Textjoin(" / ",True,Iferror(FILTER(Successions!$A$2:$A$647,RegExMatch(Successions!$C$2:$C$647,$B3),Successions!$R$2:$R$647<C$2,Successions!$W$2:$W$647>C$2),""))),"",(Textjoin(" / ",True,FILTER(Successions!$A$2:$A$647,RegExMatch(Successions!$C$2:$C$647,$B3),Successions!$R$2:$R$647<D$2,Successions!$W$2:$W$647>D$2)))),"")
The code for the leftmost column, which I did not want to check the cell to the left is:
=Iferror((Textjoin(" / ",True,FILTER(Successions!$A$2:$A$647,RegExMatch(Successions!$C$2:$C$647,$B3),Successions!$R$2:$R$647<C$2,Successions!$W$2:$W$647>C$2))),"")
Step 2
Because every cell contains a formula, I could not get the succession ID to spill into the adjacent cell and thus be readable. To solve this, I have an adjacent tab called "Map Final" that mirrors "Map 1A" via an Array Formula. Because it does not carry over formulas just values, it allows text to spill over.
Step 3
Conditional formatting is applied to "Map Final" via the Custom Formula function. There will be a rule for each crop type. Each succession is automatically colored the color of its crop type, and the color fills all cells for the duration of the succession.
My question is this:
How could I accomplish this same mapping in a more efficient way? Currently any update to Successions takes 30 seconds to a minute to update. The progress bars are killing me and basically make this really cool tool unusable for crop planning purposes, during which we are going back and forth from data to map frequently to make placement decisions.
Do you think this is possible using a custom script that pushes data rather than pulling data?
Would it render faster, or is the way I'm doing it the most efficient way?
While that is my main question, I am certainly open to any advice you have for improving speed by simply refining my current method.
Thanks in advance for any help you can provide!

Cumulative sum running on all the columns in a spreadsheet

I have a spreadsheet with a lot of columns for each year, and I need a formula that I can apply on the entire table to update the cumulative sum. Better explanation in the picture below:
The top part is how I have the table currently. The bottom part is how I need the table to be, and be able to make updates any time to any cell.
At the moment I am just having a separate 'table' of all that, where I run this formula:
=ArrayFormula(SUMIF(COLUMN(B3:J3),"<="&COLUMN(B3:J3),B3:J3))
What I need is this applied to the entire table, so whenever I make an update in any cell, it will update and run the entire cumulative sum across the years for each user.
your current solution is best you can have in Google Sheets by using internal formula functions. a small improvement can be done to have it under one formula if you stack individual rows (in your case pasted in B11 cell - based on image) like this:
=ARRAYFORMULA({
SUMIF(COLUMN(B3:J3),"<="&COLUMN(B3:J3),B3:J3);
SUMIF(COLUMN(B4:J4),"<="&COLUMN(B4:J4),B4:J4);
SUMIF(COLUMN(B5:J5),"<="&COLUMN(B5:J5),B5:J5)})
if you seek for instant cumulative calculation on a given range fully editable - it could be (if) possible only with a script.

How to drag formulas down every night at midnight?

I know little to nothing about code so please bear with me. I am just wondering if it is possible to use google scripts to automatically pull down formulas every night at midnight so I don't have to. I have looked online and don't yet have the knowledge to adapt various ideas to my task. Here is what I need, as best I can describe at the moment:
In sheet (this sheet) start at cell C33 and go down until you identify the last value in that continuous range of data. This is equivalent to hitting control+downarrow. Then from that bottom-most cell, for instance, C191, identify the last value to the right (equivalent to hitting control+rightarrow). So now your range is C191:Z191. Once you have identified that range, drag it down. I am dragging down formulas and I want them to stay as formulas, not be pasted as values.
I just want it to run automatically every night at midnight if possible. That's it except for 1 pretty annoying exception. On the first day of the month still drag everything down as normally but do NOT drag down the second cell to the right (which would be in column E). So for instance, you would then drag down C191:D191 and F191:Z191
Sorry for basically asking for a complete answer, but I figured I may as well before spending however many weeks learning the requesit skills to understand and write this script.