Calculate the average of the top 80% of values in a column Google Sheets - google-sheets

How can I get the top 80% of an unsorted column of values that includes 0s?
values
1
1
0.3333333333
1
1
1
1
1
0
0
If the top 80% of values to average is not a rational number, I need it to average both above and below the rational number:
(e.g. 11 values * 0.8 = 8.8 values to consider, so it should average the top 8 and the top 9 values)
so far I've this: =AVERAGEIF(A1:A12,">"&PERCENTILE(A1:A12,80%))

do it like this:
=IFERROR(AVERAGE(INDIRECT("A1:A"&COUNTA(A1:A)*80%)),
{AVERAGE(INDIRECT("A1:A"&ROUNDDOWN(COUNTA(A1:A)*80%)));
AVERAGE(INDIRECT("A1:A"&ROUNDUP(COUNTA(A1:A)*80%)))})

If by 'top 80%' you mean the largest 80%, I would use sortn:
=average(sortn(A:A,rounddown(count(A:A)*0.8),,1,false))
and
=average(sortn(A:A,ROUNDUP(count(A:A)*0.8),,1,false))
The average of the top 8 numbers is 7.5 and the average of the top 9 numbers is 7.

Related

Google Sheets Formula for Grouping Data and then finding the Median Value

Example data:
Category
Value
Blue
200
Blue
200
Red
360
Green
300
Red
400
Green
300
Yellow
0
Red
0
Pink
800
Silver
900
----
----
MEDIAN
330
MEDIAN OF CATEGORIES
???
The formula being used to calculate the median of all values (above 0) is
=MEDIAN(FILTER(B2:B11,B2:B11>0))
What formula would I need to use to Sum the Values of each category, then find the Median of the categories?
At this time I can only do this with a pivot table and the result is 760.
In its actual use case, the unique colours will change regularly and I could end up with several hundred.
Thank you!
You can use something like this
=MEDIAN(FILTER(SUMIF(A2:A, UNIQUE(A2:A), B2:B), SUMIF(A2:A, UNIQUE(A2:A), B2:B)>0))
This works for me:

SPSS - how to rescale the x-axis

How to rescale the x-axis in spss? I have a graph like this:
I would like to rescale the x-axis from 1 to 5, even if the data for 1 and 5 has 0 percentages.
Thank you very much.
I think you should label all the values of the variable of the X axis for them to appear.
According to this source SPSS defaults at showing empty categories as long as they are labeled:
https://www.ibm.com/support/pages/how-display-empty-or-unselected-categories-spss-standard-charts
So, in syntax.
Value Label variable_of_x_axis
1 "1"
2 "2
3 "3"
4 "4"
5 "5".
Or you can label them using the user interface.

How to eliminate highlighting duplicates in google sheets conditional formatting

I have a spreadsheet where I need to conditional format/highlight the lowest 3 scores in a row to reflect dropped scores that are part of a Total calculation. I'm using the SMALL function to successfully calculate the Total..=SUM(A2:I2)-SMALL(A2:I2,1)-SMALL(A2:I2,2)-SMALL(A2:I2,3) but when I try to use the SMALL function in the Custom Formula field of the Conditional Format it highlights 0,60,60,60 and not 0,60,60
119 101 60 100 0 109 60 60 112 TOTAL:601
If four of the values are 0, it will highlight all for 0's.. if 60 is the lowest score and there are 4 or more scores of 60, it will highlight all and not reflect that only 3 of the scores are actually dropped.
Is there another way (custom formula) that can only highlight the lowest 3 scores in the row even when the 3rd lowest may have duplicates in the row?
I've come up with this formula (assuming values start in A1) which unfortunately is a bit long
=OR(A1<SMALL($A1:$I1,3),AND(A1=SMALL($A1:$I1,3),COUNTIF($A1:A1,SMALL($A1:$I1,3))<=(3-COUNTIF($A1:$I1,"<"&SMALL($A1:$I1,3)))))
or
=OR(A1<SMALL($A1:$I1,3),AND(A1=SMALL($A1:$I1,3),(COUNTIF($A1:A1,SMALL($A1:$I1,3))+COUNTIF($A1:$I1,"<"&SMALL($A1:$I1,3))<=3)))
The logic is that it highlights all cells which are less than the third smallest value, then any values (starting from the left) which are equal to the third smallest value until the total equals three.
I've changed the second row to show that it selects the second zero instead of the second 60.

Auto correlation of a row vector

I want to take auto correlation of a row vector of length 1x2080, as i want to take first 52 numbers(from 0 to 52) and then correlate with this row then i want to take from next 52 from (1 to 53) and then so on for example next i will take next 52 (2 to 54) and the correlate this with row so at the end of the day i can check where the auto correlation is high.I am trying to implement a for loop for that for example for i = 1:52:2080
autocorr(i+51,a)
end
where a contains the row vector of containing numbers for autocorrelation

Calculating the sum of all values in an array larger than a value in another cell

I'm perfectly aware of the sumif() Function in Google Sheets.
A B
1 15
2 20
2 10
3 30
5 45
1 10
When I want to calculate the sum of all values in the array smaller then 3, I can use SUMIF(A:A;"<3";B:B) .
When looking for all values equal to another cell value (C1), I can use
=SUMIF(A:A;C1;B:B).
But I can't find a way to calculate the sum for all values for all cell values smaller then the cell value in C1 SUMIF(A:A;<C1,B:B) doesn't work. What do I do wrong?
To sum all values in B:B that correspond with values in A:A that are smaller than a value housed in C1:
=SUMIF(A:A;"<"&C1;B:B)

Resources