I have my data organised in a NxN table with coupled columns {quantity,code} (see image below).
I'm looking for a function able to calculate total quantity by code.
I've tried with SUMIF, but it seems to work only with a fixed sum range, whilst I need a RELATIVE sum range.
Can you address me to the right solution?
i think this should work:
=ARRAYFORMULA(SUM(A2:G4*(B2:H4=A7)*(A1:G1="quantity")))
just using multiplication of booleans to get at the correct values is sometimes simpler.
Related
I was faced to a situation where I have to classify a list of numbers based on the size of the number.
For example, number between 2 and 8 is classified in class A. Number 16 to 25 is classified in class C. I can work on it with IF formula, but it doesnt feel good since it was like brute forcing IF within IF within IF and it is bad.
Is there any ARRAYFORMULA that can help me work on this? An arrayformula that doesnt need to be dragged down when data is added below. Maybe a formula that is related to VLOOKUP or any other formula will do.
This is the sample case:
https://docs.google.com/spreadsheets/d/1Dlrgp-aAlU2DknlG5u5XWJdXDpU5qj6EfofiCO3UTDQ/edit#gid=0
Range A:A is the given data
Range B:B is the desired outcome
Range E:F is hte condition that has to be met
You can do a lookup on the lower end of each range:
=ArrayFormula(if(A:A="","",vlookup(A:A,{split(E1:E9,"-"),F1:F9},3,true)))
assuming there are no values more than 1200.
I have some "complex" calculation that I currently do row-by-row and store in a helper column. In the end I simply run a sum on the helper column to calculate the total value of that calculation.
I would like to simply have one field, where I do the calculation of the total value - without needing the helper column.
To be concrete, I am calculating exertion load (XL): http://www.strongur.io/monitoring-training-stress-with-exertion-load/
As input data I get a weight lifter, repetitions performed and how many reps were in the tank until failure (RIR) is reached. I calculate the XL of a set by expanding the reps performed into a range => 3 reps becomes [1,2,3] and then running an ArrayFormula on that range to calculate the distance to failure from the perspective of that rep (rep 1 is further from failure than rep 3) and consequently the XL of that single rep. I then use a sum to calculate the total exertion load of the given set.
Unfortunately, this approach does not scale to the "single field"-solution - as I cannot add another ArrayFormula around it. I am not sure where to go from here - my spreadsheet experience is limited.
I think I am missing something here from a conceptual perspective - I've been doing some googling and have seen matrices mentioned, would that be the right direction for this kind of thing? I would like to avoid having to write a JavaScript function just for this use-case.
Thanks in advance for any tips/pointers! :)
Best Regards,
Simon
Sample Spreadsheet: https://docs.google.com/spreadsheets/d/1CNYxsQKo_CUIsstCDbcjoojL6WK46rg9ONybviFxAGs/edit?usp=sharing
use:
=ARRAYFORMULA(SUM(IF(B2:B="";;IF(COLUMN(1:1)>C2:C;;
B2:B*EXP(-0,215*(D2:D+C2:C-COLUMN(1:1)))))))
I'm making a spreadsheet that includes a long list of values, with a column that contains a total of values, and after that an average of the values in the row. I need the averaged column to always be 1/6 of the value in the summed column, but I can't figure out a way to make it automatically calculate it for me for each new row.
So far, I have been doing it all manually (type out all the values, manually add them together for the total, then divide by 6 myself for the average) but I'd really like to automate the math parts. I have not found a single way to properly do this - using "=DIVIDE(K2,6)" as a modified version of a suggestion on this other question (modified to use the column I'm actually putting the numbers in) does literally nothing, and I'd have to manually change and paste it into each row, which is actually harder and more tedious than continuing to do the math myself.
Here's an example image of what my columns look like. All the math is correct so far, I just want to automate it so I can type fewer numbers:
EDIT: Combined answers from Scott and Player0 is what worked! thanks for being patient with me! I was able to also use that to make the Sum column function automatically as well, so both columns are fully automated now! :D
You don't have to enter the formula manually on every line.
Enter =K2/6 in cell L2; then select cell L2
and drag/fill it down to L12.
(That means click on the dot in the lower right corner of the cell
and drag it down.)
Or however far your sheet actually goes.
That will automatically fill in L3 with =K3/6,
L4 with =K4/6, and so on.
use on row 2:
=INDEX(IFERROR(K2:K/6; 0)
also see: ArrayFormula of Average on Infinite Truly Dynamic Range in Google Sheets
I am trying to use AVERAGEIFS inside ARRAYFORMULA. Looking at other questions, I have come to the conclusion that it is not possible without using QUERY function.
My intention is to average the values of a column whenever they share the same ID.
I think this question comes pretty close to what I need, but I haven't been able to replicate and adapt its solution on my own sheet.
In this sheet I show the result I expect (I got it by dragging the formula). I've also reviewed the Query Language Reference, unsuccessfully.
Thanks a lot for your time and effort.
So the formula should be
=ArrayFormula(iferror(sumif(A2:A,A2:A,B2:B)/countif(A2:A,A2:A)))
Note that if there were any text values in the points column, this would still return a result (because count would be greater than zero) - you could instead use
=ArrayFormula(if(isnumber(B2:B),(sumif(A2:A,A2:A,B2:B)/countif(A2:A,A2:A)),""))
If you had a mixture of rows with text and rows with numbers for any ID, this would return a smaller result than the avg or average formula. This is a limitation of this method. You can't put an extra condition in (that column B has to contain a number) because you would need countifs and countifs isn't array-friendly. It still seems strange that AFAIK countif and sumif are the only functions out of this family that are array-friendly while countifs, sumifs, averageif etc. are not.
you can do:
=ARRAYFORMULA(IFERROR(VLOOKUP(A2:A; QUERY(A2:B; "select A,avg(B) group by A"); 2; )))
This is for Google Sheets or I could also write a script for it.
I am a teacher and am trying to create a formula or function that will calculate the distance a range of test scores are away from a set number (70 -- a passing grade).
I have my data in a column as a variety of percentages. I would like the formula or function to first check the range for any values that are less than 70. Then, for the values that are less than 70 it would figure out how far each of those values are from 70 and add them all together. Finally, it will take the sum of the added values and divide by the number of values that fit the criteria (less than 70).
Any ideas on how I would accomplish this? Thanks!
There are numerous formulas you can use: sumif, countif, and averageif
But if you want a dashboard-like spreadsheet that gives you quick summaries, filter is very useful.
Here is an examples of using filters
In particular, the formula is =average(arrayformula(filter(B2:B10,B2:B10<70)-70)), where
filter(B2:B10,B2:B10<70) gives you B values that are < 70
filter(…) - 70 finds the difference
arrayformula(…) is needed because you are working with an array
average(arrayformula(…)) finds the average of the array