Data validation in google sheets based on the sum - google-sheets

I need to block a column (let's say column A) when the sum of the values in it reaches 50. So for example in cell B2 i make =50-sum(A1:A1000). Then for a A1:A100 i make a data validation with a custom formula "=B$2$>0" and click "Reject input". It works great with one big but. Data validation acts before the sum formula, so when you enter the value that actually make the sum above 50 it accept it. Only the next value entered after the sum is above 50 is rejected. Is there a way to reject also the value that actually cross the desired sum level?

Try setting your custom validation rule (on A1:A1000) to:
=sum($A$1:$A$1000)<=50

Related

Summing a range based on whether other non-contiguous cells contain text or numbers

I am trying to add a range of numbers only if the corresponding cells contain numerical values.
I am working on a grade tracking document where every assignment contains a different weighting. When students do not write the test an NA is entered. I would like to check which cells contain numerical values and add the corresponding weightings.
In the image above, the '%' column is automatically calculated and I would like this new formula to seek information from the 'Mark'column.
I tried this formula but it doesn't exclude NA and I am unsure how to include ISNUMBER to use this instead, Or maybe there is something else entirely I should be trying.
SUMPRODUCT(--(CHOOSE({1,2,3,4,5,6,7,8},B31,F31,J31,N31,R31,V31,Z31,AD31)>0),CHOOSE({1,2,3,4,
5,6,7,8},L5,L6,L7,L8,L9,L10,L11,L12))
L5 to L12 contain the weightings I would like added. L5 corresponds to B31, L6 to F31 and so on...
I would like to check if B31,F31,J31,N31,R31,V31,Z31,AD31 are numerical values and then add the corresponding cells in Column L.
Are you using SUMPRODUCT because you need to multiply L5*B31,L6*F31.... and sum the result??
If that's so, you can use it like this:
=sumproduct(L5:L12,arrayformula(iferror({B31;F31;J31;N31;R31;V31;Z31;AD31},0)))
It it's a text or an error (that's why the arrayformula and iferror) it will be considered as "0". If "NA" is not an error and there aren't any chances of having one you can just use:
=sumproduct(L5:L12,{B31;F31;J31;N31;R31;V31;Z31;AD31})
Considering your given sample, you could divide this result by a sumif of the total marks of the tests the student actually took. With your new ranges that would be:
=sumproduct($H$4:$H$8,{C15;E15;G15;I15;K15})/sumif({C15;E15;G15;I15;K15},">0",$H$4:$H$8)
Or with the previous ones:
=sumproduct($L$5:$L$12,{B31;F31;J31;N31;R31;V31;Z31;AD31}/SUMIF({B31;F31;J31;N31;R31;V31;Z31;AD31},">0",$L$5:$L$12)
https://docs.google.com/spreadsheets/d/1wjvlK74nbUM7NfvG23fQL_T6fin6FL6YpYAxjsMV9sk/edit#gid=0

Is there a way to conditionally format data validated entries to change the values within the cells themselves?

I have an attendance sheet I'd like to edit that has data validation pertaining to credit applied towards the overall attendance percentage, with a 1 meaning the person was there, .5 for late, 0 for calling off appropriately, -0.5 for calling off late, and -1 for no call not showing. In attempting to equate these numbers to the words associated with them, I'm not seeing a way to either: A) Make this human-readable with the entry of a 0.5 inside of the box being changed to late, but also usable within attendance calculation, or B) be able to pseudo enumerate my list of words to associate them with numbers
I've attempted to use most of the data validation and conditional formatting options, but I'm unfamiliar with the custom code that could be run to make this a possibility.
This is a copy of the sheet: https://docs.google.com/spreadsheets/d/1IXZqySfbED2TCX-yo1aScupdof1WZXhdQ820zlqiMn8/edit?usp=sharing
Under the Attendance tab
paste in B2 and drag down:
=IFERROR(ARRAYFORMULA((SUM(IFERROR(VLOOKUP(TRANSPOSE(C2:2),
'Data Validation'!C:D, 2, 0))/COUNTA(C2:2))*1)))

Query Importrange in Google Sheets Not Importing Correctly

We are using Google Forms to collect data on our students. They use the same Google Form for all students, but as part of the form, they are asked the students name.
The data that ends up being collected you can see on the tab Form Responses 1 on the Google Sheet linked here.
I am attempting to use ImportRange to create a tab for each of the students. The formula that I am using for just one of the students is...
=QUERY(IMPORTRANGE("1nJANDP1fiQunxfxEf-EjwJrnIRICv6kLhYYY9XBXtD4", "Form Responses 1!A:I"),"SELECT * WHERE Col3 = 'Adam N.'")
You can take a look at the tab called Adam N. and you'll see it is kind of working.
One thing that doesn't seem to be working is when there is a text value in columns E-I, that text value doesn't end up showing on the Adam N. tab. Any ideas how I can get both the numbers and the text values to show up?
The other thing that seems to be a problem is the fact that on the Adam N. tab, the very first row has the same headers as the Form Responses 1 tab, but it also has the very first line of data. Any way to remove that?
Importrange is not needed since you are 'importing' from within the same spreadsheet. Also, I'd recommend using the (optional) header argument in query().
It is often noted that users are tempted to mix data types within a column. The query() function will give undesirable output. If a column is intended for numeric values then only numerical values must reside in that column. Date columns must only contain dates and text columns only contain text values.
This does not mean that numbers cannot appear in a text column as long as they are in a text format. So it is important to plan the columns in a table to make sure this rule is maintained regardless if the data table is created manually or via submissions from a Google Form.
Generally, the query() function will assume the greater number of cell types in a column to be that data type. For example, if there are 100 numbers and 20 text values in the same column then a numeric value will be assumed for that column. There is a good chance the text values will just be ignored. One way to avoid this, would be to convert everything to text.
See if this works
=ArrayFormula(QUERY(to_text('Form Responses 1'!A:I),"WHERE Col3 = 'Adam N.'", 1))

Google Spreadsheet: Summing up a range by using numeric value in another cell

I'm an AP Biology student and am trying to create a mathematical model for a Hardy-Weinberg lab using Google Spreadsheet. Here is the link to the spreadsheet. The problem is located on the "Gene Flow" tab on N111.
So I am trying to add all the number values above N until it hits a certain number. That quantity of organisms is dependent on the total number of organisms AFTER the migration of Generation 1. And that migration is just random chance of whether some will leave or arrive. By adding up the new generation, I need to calculate the genotypes of their offspring (a.k.a. Generation 2), assuming there is 1:1 ratio between each generation.
Here is the code I tried:
=SUM(N6:N(SUM(F107:H107)+6))
However, the error I receive is Argument must be an range.
Is there a way to properly express this through Google Spreadsheet?
You could use the INDIRECT function. It returns a cell/range reference with only a string as input. For example:
=SUM(INDIRECT("N6:N"&(SUM(F107:H107)+6)))

Select value from range based on match

I've got the following set of data and have setup a another table to the right which holds the cost of each location.
The cost column currently I've got =IF(EXACT(B2,"Home"),D2*17.2,D2*0.09), however the cost per kWh can change based on different locations. I want to be able to lookup the cost based on another table which will make things more manageable.
You can put this formula in E2:
=VLOOKUP(B2,$G:$H,2,FALSE)*D2
It will take the value in B2, find it in the G column, take the value from the cell right to that match in the H column. This is the Cost per kWh, so it gets multiplied by D2 to arrive at the cost.
The FALSE is needed to require an exact match.
Drag/copy down the formula to the other cells in the E column.

Resources