I am trying to find a formula that will allow me to calculate MAX/MIN without calculating anything after the current row - excel

I want to use the Max/Min function to calculate the minimum number up to the current row, but not count anything after that row. See example below:
A B C
1 10 =MIN(A1:A1) I Want B1 to only count MIN from A1 to A1 from here, then
2 14 =MIN(A1:A2) from here I want B2 to count MIN from A1 to A2,
3 9 =MIN(A1:A3) Then A1 to A3,
4 6 =MIN(A1:A4) etc,
5 14 =MIN(A1:A5) etc.
I could go back and update each row manually, but I have over 700 rows that I want all this to apply to. Is there anyone who can help me with a solution to this problem?

Use this formula in B1, and copy downwards:
=MIN($A$1:$A1)
This is called maintaining referential integrity while writing any excel formula. It should give the desired result on copy towards right or downwards.

Related

COUNTIF to calculate number of occurances between 2 values

I have no idea what is wrong with my formula and I would like to learn from my mistakes:
I have a range of values, say A1:A100, and I want to count the number of times a value from 0 to 10 appears, 10 - 20 appears etc. and put it into a frequency table.
I am put value 0 and 10 in cells B1 and C1 respectively, 10 and 20 in B2 and C2 respectively etc. (i.e. the frequency table is from columns B to D)
In D1, my formula is:
=COUNTIF($A$1:$A$100,AND(">="&B1,"<="&C1)
However, this formula doesn't seem to work and always returns 0. It would be greatly appreciated if anyone can enlighten me on why my formula doesn't work. Thanks in advance!
Use COUNTIFS for multiple conditions.
=COUNTIFS($A$1:$A$100, ">="&B1, $A$1:$A$100, "<="&C1)

Formula to add a number to the cell and change that value if it is greater than certain number

In Column A I have numbers from 1 to 30 and in Column B I want to add 10 to the number in column A i.e.
if A1 is 1 I want 11 in B1 and in C1 I want 21 and
if A2 is 2 I want 12 in B2 and in C2 I want 22.
I don't want the numbers in columns B and C to exceed the maximum limit of numbers I have in Column A, in this case that is 30.
I need a formula to achieve this so that none of the cells in column B and C has the number exceeding 30 and if the addition exceeds that I want 30 to be subtracted from it. I tried this with IF but it didn't help as I don't know how to manipulate the current cell after adding the number.
Screenshot of expected results:
I want the number in B Column to be addition of 10 to the number in A Column and it should not exceed maximum number.
Maybe, in B1:
=A1+10-30*(A1+10>30)
and in C1, both copied down to suit:
=B1+10-30*(B1+10>30)
Considering B1, the above can be simplified slightly by rendering (A1+10>30) down to (A1>20).
A1+10 is the basic requirement.
The condition is that where A1+10 exceeds 30, a deduction of 30 should be applied. This can be restated as "where A1 exceeds 20".
(A1>20) returns either TRUE (when A1 is more than 20) and FALSE (otherwise).
What may not have been appreciated by all is that when used as a multiplier, Excel treats TRUE as 1 and FALSE as 0.
So when A1 is less than or equal to 20, nothing is deducted from to A1+10. 30*(A1>20) becomes 30*FALSE (effectively 30*0), which is 0. However, when A1 is more than 20 30*(A1>20) becomes 30*TRUE (effectively 30*1), which is 30.
The formula for B1 is:
=IF(A1+10>MAX($A$1:$A$30),A1+10-MAX($A$1:$A$30),A1+10)
(For C1 just do "Fill Right" from B1.)
Sometimes it's better to use several columns to get to the result:
First I created in D1 =A1+10, then in E1 =MAX($A$1:$A$30).
The $ means that the column or row number does not change when you fill down, so A1 stays fixed to A1 in every cell.
In F1 I created an IF formula: =IF(D1>$E$1,D1-$E$1,D1) which means "IF D1 exceeds the highest value in A1 to A30 THEN subtract that highest value from D1 ELSE just display D1 (=A1+10)"
And if you substitute these values:
(E1): =IF(D1>MAX($A$1:$A$30),D1-MAX($A$1:$A$30),D1)
(D1): =IF(A1+10>MAX($A$1:$A$30),A1+10-MAX($A$1:$A$30),A1+10)
you get the result I mentioned in the first place.

excel sort columns in groups of 2

I've a data in a row looking like this ->
5 0.1 3 0.5 9 17 1 0.1...
These are in groups of two, i.e., 0.1 is associated for 5 & 0.5 for 3 & so on
I want to sort the row in groups of two ->
1 0.1 3 0.5 5 0.1 9 17
This is a real formula hack but it solves your question as posted at face value.
There is a caveat that if there are ties in numbers, this will not work as accurately as your sample data.
Formulas are explained below the picture:
A5 -> =A1, then drag over skipping columns
A7 -> =IF(ISBLANK(A5),A1,""), then drag over all columns
A4 -> =IFERROR(RANK(A5,$A$5:$H$5),""), then drag over all columns
B6 -> =IF(B4="",A4,""), then drag over all columns
A9 -> =COUNT(A1:H1)/2, rest of columns are just math.
A10 -> =HLOOKUP(A9,$A$4:$H$5,2,0)
B10 -> =HLOOKUP(B9,$A$6:$H$7,2,0)
copy A10:B10, over for each two columns.
Three methods depending on actual data structure
Method 1:
If the cells on which you wish to sort are not duplicates, you could do this:
In A2 put:
=A1
In B2 put:
=IF(MOD(COLUMN(),2) = 0,A1+(B1/1000),B1)
Then drag the whole width of the data:
Copy and paste just the values on row 2. Then sort horizontally on row 2:
Then you can delete row 2
Method 2:
If there are duplicates then this two step process will get you then list desired
In A2 put:
=IF(AND(MOD(COLUMN(),2),A1<>""),A1+(B1/10000),"")
In A3 put:
=IFERROR(IF(MOD(COLUMN(),2),INT(SMALL(2:2,ROUNDUP(COLUMN()/2,0))),(SMALL(2:2,ROUNDUP(COLUMN()/2,0))-INT(SMALL(2:2,ROUNDUP(COLUMN()/2,0))))*10000),"")
And copy across all columns. Row 3 will be your sorted list:
The advantage to this method is that you can paste the values of the list in row one and it will calculate the correct sort order on calculate. There is no copying and pasting over formulas.
Method 3:
If you want to go the column route then:
In one column put:
=OFFSET($A$1,0,(ROW(1:1)-1)*2)
In the second:
=OFFSET($A$1,0,(ROW(1:1)*2-1))
Then copy down sufficient to get all the values.
Then copy and paste the values anywhere you want and then sort.

Excel countif(s) multiples

I'm trying to calculate the count of multiple occurrences of a figure using countif.
I have the range set but I need a calculation which can count in multiples of 50 without me having to type thousands of versions of countif (=COUNTIF(B2:B5,">=50")-COUNTIF(B2:B5,">100" etc.).
Data Count
50 1
70 1
80 1
10 0
150 3
This data should show 6 but at the moment I'm getting 4.
First you can start by making bins. you can make it with Data analysis tool or half manual
Like in the example, on A2 enter 0 and on b2 enter =a2+50
Same goes for a3 enter =b2 and last on a4 =a3+50
Now you can drag it down as much as you like.
Instaed of using countif use sumif finction. let's assume your data is on cloumn H and the values you want to sum are in column I, then on c2 enter
=SUMIFS(I:I,H:H,">"&A2,H:H,"<="&B2)
you can drag it down as much as you like.
Simply use Excels ROUNDDOWN function:
e.g. for B2: =ROUNDDOWN(A2/50,0)

Finding Top 15 or Top 10% Highest Values in Excel

So I will have a list of players (for fantasy baseball) that includes what team they are on and their salary - 3 columns in total. The number of players will range but could be in the 100-238 range. 238 is the max though.
I need to find the top 15 or 10% most expensive players, whichever is higher once we're done drafting. Therefore I will either have 15 players (if my list is <= 150) or will be the 10% once it gets to 155 and higher (since we're rounding).
Since based on my max I know I'll have anywhere from 15-24 players to pick from I had the following formula in a grid and just dragged down 24 rows. Column I is just numbered 1-24.
=IF(OR(COUNTIF($B$2:$B$501,"*") < 150, I3 <= ROUND(COUNTIF($B$2:$B$501,"*") * 0.1,2)),INDEX($B$2:$B$211,MATCH(1,INDEX(($D$2:$D$211=LARGE($D$2:$D$211,ROWS(J$1:J1)))*(COUNTIF(J$1:J1,$B$2:$B$211)=0),),0)),"-")
However, something is wrong as I keep getting duplicate names when I test this out with test data.
Any ideas where I am wrong?
The difficulty is duplicated salaries.......this can be accomodated......say the data is like:
Clearly Christopher, Mark, and George all share the same salary...to untangle this in E2 enter:
=RANK(D2,$D$2:$D$23,0)+COUNTIF($D$2:$D2,D2)-1
and copy down...........this assigns a unique ID to each record.....In G2 enter:
=MATCH(ROW()-1,$E$2:$E$23,0)
and copy down...in H2 enter:
=OFFSET($B$1,G2,0)
and copy down...in I2 enter:
=OFFSET($C$1,G2,0)
and copy down...finally in J2 enter:
=OFFSET($D$1,G2,0)
and copy down...........we now have:
This is a "sort-by-formula"..........Pick as many names off column H as you choose!

Resources