Let's say my formula is in D2. I want to sum the value from previous column with another sheet column and do it for all rows, I can do the following:
=ARRAYFORMULA(C2:C+AnotherSheet!D2:D)
Now I would like the next column to do the same:
=ARRAYFORMULA(D2:D+AnotherSheet!E2:E)
How would I set it up, so it works for all columns without manually copy pasting this formula to the next column.
This quick and dirty brute force formula might be some help, depending on how many columns you need. Try this:
=ARRAYFORMULA({C2:C+Sheet2!D2:D,
C2:C+Sheet2!D2:D+Sheet2!E2:E,
C2:C+Sheet2!D2:D+Sheet2!E2:E+Sheet2!F2:F,
C2:C+Sheet2!D2:D+Sheet2!E2:E+Sheet2!F2:F+Sheet2!G2:G,
C2:C+Sheet2!D2:D+Sheet2!E2:E+Sheet2!F2:F+Sheet2!G2:G+Sheet2!H2:H})
It wouldn't be too hard to automatically generate the full formula you need, if your number of columns isn't changing all the time.
But I imagine someone will come up with an elegant formula to somehow do the same thing. Let us know if this helps.
Related
I'm probably making a really simple mistake here but I can't figure it out. I'm making a simple spreadsheet that tracks runners' last 5k time and then I take their time away from the slowest runner to give a 'handicap' time. This way all the runners should finish the race together next time.
Here's the data:
And the formula is
= MAX(D2:D16) - D2
When I do a sort (by the calculated start time column, I get the #REF! error (Reference does not exist. Like I say it's probably really simple, but I can't figure it out. Any help appreciated!
The formula you are using in F2 should be =MAX(D$2:D$16)-D2, otherwise it won't even work when you drag it down. And sorting it with from the menu obviously won't do anything, since if it's a formula you dragged down, it will autoupdate to still use the same row from column D. There is however a sort function you can use either in a different column (like in G2 =sort(F2:F16,1,1)) or you could change your F2 formula to =SORT(ARRAYFORMULA(MAX(D$2:D$16)-D2:D16),1,1), so both sorting and propagation down the column are done in one.
I have a matrix - 1,172 words down column A, then the same 1,172 names across row 1. Then each word is cross-referenced with all the other names to give a similarity score (this is already done).
In another sheet, I want to look up a word, and return all the words with which it has a certain similarity score - in this case, greater than or equal to 0.33. I attach a MWE, in which I give an idea of the answer I am looking for by looking it up manually.
I think it's some sort of reverse lookup. As in, instead of finding the value corresponding to a particular row and a particular column, it's finding the column based on value in the main sheet and row. I'm just really stuck at this point and would massively appreciate some help. Thanks! MWE here
If your words on the second sheet are in the same order then:
=IFERROR(TEXTJOIN(", ",,FILTER(Scores!B$1:W$1,(Scores!B2:W2>=0.33)*((Scores!B2:W2<1)))),"-")
Drag down.
Explanation:
Filter the values from row 1 according to the similarity score condition, using FILTER.
Concatenate the filtered values using TEXTJOIN.
Is there a formula in google sheets to calculate a character only once. For example, if a row has 5 columns (Monday-Friday) and there are 2 or 3 columns marked with X. How can I calculate how many rows have an X. I don't need to know how many Xs there are just how many have an X?
Reina, I have one answer, though there may be better ones.
This formula, pasted into B34, should do what you want. It merges all the cells in column B to F, in each row, into one value, substitutes out possible spaces, then checks if it has at least one "y" (as used in your example.
=COUNTIF(ARRAYFORMULA(
SUBSTITUTE(B4:B29&C4:C29&D4:D29&E4:E29&F4:F29," ","")),
"*y*")
It is coded to search all student rows, ie. between 4 and 29 - change these row numbers if necessary.
If the attendance might be marked with something other than a "y", you could change the "y" part of the formula to "?*". I just didn't know if other values might be used, eg. an "S' for sick day or something, and you wanted to ignore those.
Then, you can drag the new formula from B34, sideways on row 34, to G34 and beyond, and it should calculate the results for the subsequent weeks. It will shift the columns being checked by the formula automatically.
Let me know if this works for you, or if you need something else.
To possibly ease data entry, here is a sample sheet with the formula, but with check boxes replacing the cells where attendance is marked.
https://docs.google.com/spreadsheets/d/1ON5Rc55aLVq_LHtFOfpgmf876bYg2ITfwpbifklr3lU/edit?usp=sharing
Here the formula is slightly modified to look for "TRUE" values, instead of "y"s.
UPDATE: To look for ANY non-blank cell in that range, and count "1" for every student that week that attended at least one day, the formula is:
=COUNTIF(
ARRAYFORMULA( B4:B29&C4:C29&D4:D29&E4:E29&F4:F29), ">""")
or
=COUNTIF(
ARRAYFORMULA( B4:B29&C4:C29&D4:D29&E4:E29&F4:F29), "?*")
See sample here:
https://docs.google.com/spreadsheets/d/1ON5Rc55aLVq_LHtFOfpgmf876bYg2ITfwpbifklr3lU/edit#gid=461771088&range=B34:F34
Let me know if this answers your question, or do you need to do something specific with the "y,x, and o"s?
I have an excel that I'm calculating my Scrum Task's completed average. I have Story point item also in the excel. My calculation is:
Result= SP * percentage of completion --> This calculation is for each row and after that I sum up all result and taking the summary.
But sometimes I am adding new task and for each task I am adding the calculation to the average result.
Is there any way to use for loop in the excel?
for(int i=0;i<50;i++){ if(SP!=null && task!=null)(B+i)*(L+i)}
My calculation is like below:
AVERAGE((B4*L4+B5*L5+B6*L6+B7*L7+B8*L8+B9*L9+B10*L10)/SUM(B4:B10))
First of all, AVERAGE is not doing anything in your formula, since the argument you pass to it is just one single value. You already do an average calculation by dividing by the sum. That average is in fact a weighted average, and so you could not even achieve that with a plain AVERAGE function.
I see several ways to make this formula more generic, so it keeps working when you add rows:
1. Use SUMPRODUCT
=SUMPRODUCT(B4:B100,L4:L100)/SUM(B4:B100)
The row number 100 is chosen arbitrarily, but should evidently encompass all data rows. If you have no data occurring below your table, then it is safe to add a large margin. You'll want to avoid the situation where you think you add a line to the table, but actually get outside of the range of the formula. Using proper Excel tables can help to avoid this situation.
2. Use an array formula
This would be a second resort for when the formula becomes more complicated and cannot be executed with a "simple" SUMPRODUCT. But the above would translate to this array formula:
=SUM(B4:B100*L4:L100)/SUM(B4:B100)
Once you have typed this in the formula bar, make sure to press Ctrl+Shift+Enter to enter it. Only then will it act as an array formula.
Again, the same remark about row number 100.
3. Use an extra column
Things get easy when you use an extra column for storing the product of B & L values for each row. So you would put in cell N4 the following formula:
=B4*L4
...and then copy that relative formula to the other rows. You can hide that column if you want.
Then the overal formula can be:
=SUM(N4:N100)/SUM(B4:B100)
With this solution you must take care to always copy a row when inserting a new row, as you need the N column to have the intermediate product formula also for any new row.
I have a large matrix as a result of using tapply with an INDEX argument of two rows from a dataframe. Most of the matrix is empty (NA).
Here is how I used tapply: latavgs <- tapply(geodata$latitude,geodata[5:6],FUN=mean) where latavgs is my resulting matrix, and geodata is the dataframe mentioned above.
Is there a way to extract only the non-NA elements from latavgs and return them in such a way that I could have the row and column listed, as well as the value? Or is there a better way to use tapply than what I've done, if I want to take the means of all values in geodata that belong to each unique pair of values from geodata[5:6]? I.e., for each unique pair in geodata[5:6] I get one mean.
Thanks for any help.
Really hard to solve this without fully look at your data.
Try this: Why does tapply take the subset as NA and not exclude them totally