I am trying to find the average of column G based on the three largest numbers in column B.
The formula I've tried is:
=AVERAGEIF(B7:B131,LARGE(B7:B131,{1,2,3}),G7:G131)
The problem is it does not average the three, but rather it only displays the column G equivalent to the largest number in column B.
Does anybody know the correct formula to use in this instance?
If the numbers are all different in column B, as you say, then you can do this most easily by averaging column G for any number in column B that's greater than or equal to the 3rd largest, i.e.
=AVERAGEIF(B7:B131,">="&LARGE(B7:B131,3),G7:G131)
If you want to get matching values (from the same row) from different columns, you can use either VLOOKUP or INDEX\MATCH, as I did here.
From that point it gets trivial. Let me know if it works for you:
=AVERAGE(INDEX(G:G,MATCH(LARGE(B:B,1),B:B,0),1),
INDEX(G:G,MATCH(LARGE(B:B,2),B:B,0),1),
INDEX(G:G,MATCH(LARGE(B:B,3),B:B,0),1))
(Please notice I assumed the values in column B are unique, as you've mentioned in your comment.)
Related
As I stated in the title, I want to calculate the sum of the first n% rows in a filtered column. The total numbers of rows in the column varies due to the filtering options, so my formula must work with different values of n.
For example :
In column A, I have 10 rows that contain values from 10 to 1 ( I sorted them from largest to smallest ).
In column B, I have 10 corresponding rows that contain 2 names: 4 of them contain the value "Tom", six of them contain the value "Jerry". When I filter the whole table and select only the rows that contain the value "Jerry", I want to be able to calculate the sum of the first 20% of the corresponding 6 number values.
This could work without any filtering if you want.
With criteria for column B in E1 and percentage you looking for in F1 with the assumption we want to round up the percentage to integers.
So formula in D1:
=SUMPRODUCT(LARGE((B2:B11=E1)*(A2:A11),ROW(A1:INDEX($A:$A,ROUNDUP(COUNTIF(B2:B11,E1)*F1,0)))))
So, without your data, I came up with this, edit to suit your situation...
So, based on the comment, I did a second version:
The helper column in col C is used with sumproduct to give the result...
You can use the percentile function in AGGREGATE with SUMIFS to do what you want:
=SUMIFS(A:A,B:B,"Jerry",A:A,">="&AGGREGATE(16,7,A1:A10/(B1:B10="Jerry"),0.8))
If you want to use the filter to do the decision:
=SUMPRODUCT(SUBTOTAL(3,OFFSET(A1,ROW(A2:A10)-1,,1))*(A2:A10>=AGGREGATE(16,7,A2:A10,0.8)),A2:A10)
Hi I have a bunch of data and I need to know how much of each value show up and how often the frequency is only corresponding to the unique value. I used a countif to count the unique value but I wanna know the frequency of the amount of times it shows up.
Sorry if this doesnt make any sense here's a screenshot to maybe help you understand better.
https://imgur.com/a/hLUY5um
Change the formula in B1 to,
=IF(COUNTIF(A$1:A1, A1)=1, COUNTIF(A:A, A1), TEXT(,))
and fill down to match the values in column A.
Copy column B into column E then Sort and Remove Duplicates¹.
This simplifies the formula in F1 to,
=COUNTIF(B:B, E1)
Fill down to match the values in column E.
¹ The Custom Number Format for column E is F\r\eq 0_).
I need to sum all values in Column A where Column B is a duplicate.
Above is a sample of the data. Column B has urls and Column A has counts for the urls. What I want is to sum the values in Column A for duplicate values in Column B.
Example:
The output for _.apelabs.net should be 6.
How can I achieve this?
I think you are looking for the function =COUNTIF(Range,Criteria)
Here is a link that shows a usage example.
As #Andresson stated, if you're trying to count the number of times a specific url appears, you might want to use the COUNTIF function: =COUNTIF(range, criteria).
COUNTIF Example:
Using =COUNTIF(B:B, "_.apelabs.net")
would return 3 in your sample data (assuming your image includes the only instances of "_.apelabs.net").
This example of the COUNTIF function is the same as saying, "count the total number of times a cell in Column B (i.e. B:B) equals "_.apelabs.net"."
However, if you're wanting to sum together all the values in Column A where the corresponding url in Column B matches the given criteria, you'll want the SUMIF function: =SUMIF(range, criteria, [sum_range]).
SUMIF Example:
Using =SUMIF(B:B, "_.apelabs.net", A:A)
would return 5 in your sample data (again assuming your image includes the only instances of "_.apelabs.net").
This example of the SUMIF function is the same as saying, "each time a cell in Column B (i.e. B:B) equals "_.apelabs.net", sum together the values in Column A (i.e. A:A) that are located in the same row as each "_.apelabs.net" found in Column B."
Additionally, you can also use a pivot table, as #ScottCraner suggested. It's all a matter in how you want to present your findings.
How can I test to make sure that the values between two cells are both non-zero?
This may be an exercise of my rustiness in certain areas of math but I have two columns of values in an excel spreadsheet. In a third column to the right, I'm taking 80% of one and 20% of another and getting the sum. However, this is throwing off the calculation I'm trying to do often because the value in several cells is zero in one but not the other. How can I only apply the 80% or 20% when both values are not zero?
If your columns are A and B, the following will work in column C:
=IF(AND(A1<>0,B1<>0),(0.8*A1)+(0.2*B1),"A value equals zero")
In plain language:
If A and B are both not equal to zero, apply the calculation.
Else, warn the user that a value in column A or B equals zero.
Edit:
In response to the comment:
=IF(AND(A1<>0,B1<>0),(0.8*A1)+(0.2*B1),SUM(A1:B1))
In plain language:
If A and B are both not equal to zero, apply the calculation.
Else, sum the two values. The sum is equal to the non-zero value in column A or B.
How do you count values in column E if the date in column F is greater than today.
This is what i have so far - but it returns 0.
=COUNTIF(E:E,F:F>=TODAY())
Please try:
=COUNTIFS(E:E,"<>",F:F,">="&TODAY())
Not sure why you are trying to use column E at all. The number of corresponding cells in E is the same as the number of column F cells matching criteria. It is irrelevant to finding the number of values in column F greater than today. First parameter is the range you want to count values in and the second is just the criteria. Try this:
=COUNTIF(F:F,">="&TODAY())
I prefer using sumproduct. THis can be used to count and find a weighted average. For counting, you wrap the range in --() and anything within that row is counted as 1. If you include a conditional statement, the row is only counted if the condition is true. You can add several conditions to filter out more data as needed. In the field below, I have the current date set to F12 or you can use the current date.
=SUMPRODUCT(--(E2:E10),--(F2:F10>F12))
There seems to be a bit of confusion about wether you want to count or sum the values in column E if the date is equal to or greater than todays.
Here's the sum formula
=SUM(IF(F2:F5>=TODAY(),E2:E5,0))
Hit ctrl+alt+delete so you get the curly brackets.
It should look like {=SUM(IF(F2:F5>=TODAY(),E2:E5,0))}
Use the same formula but with count if you want it to count.
=count(IF(F2:F5>=TODAY(),E2:E5,0))
Again, use ctrl+alt+delete