Cumulative count that starts again when value in column changes (EXCEL) - excel

I have 4 columns (although only need to know about 3):
Column A - An index that counts up from 1 and then resets to 1 after a certain period
Column B - A decision Boolean that is '1' for successful and '0' for rejected
The column I need help with is:
Column C - What I want is that whilst the index in Column A is counting up, for it to total up (cumulatively) the number of 1s in column B, but then reset when the index in Column A goes back to 1. I have manually started this, but would love a way of doing this automatically through a formula or VBA
Any ideas? I have hosted the data at the following link if anyone could help.
https://1drv.ms/x/s!Aqd9Lw8Wn3YHgeUPYjb7v5kIeWmq6A

Use this formula:
=SUM(INDEX(B:B,AGGREGATE(14,6,ROW($A$1:INDEX(A:A,ROW()))/($A$1:INDEX(A:A,ROW())=1),1)):INDEX(B:B,ROW()))
EDIT:
I was way overthinking the above formula use this much simpler formula:
=IF(A2=1,B2,C1+B2)

Related

filter values between -1 and 1 excel

I have an excel column with some interesting data, but a lot of positive and negative values that are insignificant.
So I would like to turn all the values -1<0<1 into zero.
What would be the best way to do this?
Any help would make my day.
You could use a simple IF condition for this task.
Assuming you have your data in column A, use the below formula in column B and drag it down,
=IF(AND(A1<=1,A1>=-1),0,A1)
You could later use this column as reference. If you want to ignore 1 and -1 , then remove the = sign within the AND function.
=IF(AND(A1<1,A1>-1),0,A1)

Excel: How do I sum cell values every nth colum

I have the following table:
and I'd like to have the total for each player but values are every 3 columns.
As you can see from the picture on the bottom part I wrote what manually I should enter.
For player 1
=SUM(D3;G3;J3...)
Player 2
=SUM(D4;G4;J4...)
and so on. What formula should I use to calculate automatically every 3 columns? I know how the MOD works but on the net I found too many examples each one using different methods and none worked so far. Can anyone help me please or point me to the right direction to understand how it works to get this data since I'll be using this a lot (get value from cell every nth column).
thanks
It looks like you should just be using SUMIFS here:
=SUMIFS(3:3,$2:$2,"TOT")
This will sum every value on row 3 (Player 1) where the value in row 2 is "TOT" (every 3rd column). Put this in cell B18 and just copy down in your column B.
Or, in case you change your column labels, you can refer to cell D2 instead of typing "TOT" in the formula:
=SUMIFS(3:3,$2:$2,$D$2)
Try this, it will total all the cells that occur every 3 columns beginning at column D. Z3 can be increased to any column you require:
=SUMPRODUCT((D3:Z3)*(MOD(COLUMN(D3:Z3)-1,3)=0))
The explanation on how it works can be found here (I advise you to bookmark this site for future references. They have many other helpful formulas and functions).
Applying this formula to your reality should be something like this for Player 1 (Not tested. Adjust the ranges as required):
=SUMPRODUCT(--(MOD(COLUMN(D3:Z3)-COLUMN(D3)+1,3)=0),D3:Z3)

Complicated SUM formula

I'm having a nightmare trying to come up with a formula to solve the following issue. I have two columns 'Record Count' and 'Actual Hours', where record count is greater than 1 I need to sum the data in actual hours. If possible I only want to use one formula and the maximum record count that I can see is 5.
So if you check out the image below, for the rows where the are 5 records I want to see 15.75.
This would be the sum of 1.19, 1.75, 2.31, 3.5 and 7 as these all relate to a single client.
enter image description here
Looks like you want to get total time for each clientid. In that case it does not matter whether there is one or more records for the client. Assuming, clientid is column C and Actual hours column D, in B2 enter =SUMIF(C:C=C2, D:D). Copy all the way down.
Looks like a task for SUMIF():
=SUMIF(A:A,">1",B:B)
(assuming A:A is 'Recoud Count' column and B:B is 'Actual Hours')
This will get you the sum of hours where record cound is more than 1.
Starting from second record you can do partial sums. Here B is record count, C is client ID, D is actual hours. For second line (E2):
=IF(AND(B2>0,C2=C1),E1+D2,IF(C2>0,D2,0))
For A2:
=IF(C3=C2,"",E2)
It uses two formulas, requires to move whole table one row down and only places one entry against each client. If this is works for you - give it a try.
If you don't want to move data you can paste this formula in E2:
=IF(ROW(E2)==1,IF(B2>0,D2,IF(C2>0,D2,0)),IF(AND(B2>0,C2=C1),E1+D2,IF(C2>0,D2,0)))
If the row is first the rows above are ignored (avoiding nullPointerException). If the row is second or below it works does the comparison to see border of userid.

Excel: Need to sum the lowest 5 values from a column of 10

Trying to build an Excel formula that will sum the 5 lowest golf scores out of 10. Currently using a table setup, provided by another forum, but it's not quite getting me there, as I think it's ignoring duplicates. The letter 'E' should also be equal to the value of zero.
Screen shot: http://imgur.com/G8xoul9
Here are the formulae in use, identified by cell:
G17: =SUM(IF(G5:G14<=G25,G5:G14)/COUNTIF(G5:G14,G5:G14))
G21: =MIN(G5:G14)
G22: =SMALL($G$5:$G$14,COUNTIF($G5:$G14,"<="&G21)+1)
G23: =SMALL($G$5:$G$14,COUNTIF($G5:$G14,"<="&G22)+1)
G24: =SMALL($G$5:$G$14,COUNTIF($G5:$G14,"<="&G23)+1)
G25: =SMALL($G$5:$G$14,COUNTIF($G5:$G14,"<="&G24)+1)
The result in G17 should be -7, but I'm not getting there just yet. Your generous help will be greatly appreciated. Thank you!
Try this, entered as an array formula (CTRL-ENTER):
=SUM(SMALL(scores,{1,2,3,4,5}))
where scores is the range of cells with your scores
Update for Google Sheets
This can also work in Google Sheets, but it seems like it requires an ArrayFormula. You enter the above with CTRL-SHIFT-ENTER or manually type the array formula:
=ArrayFormula(SUM(SMALL(scores,{1,2,3,4,5})))
You have made this more confusing than it needs to be.
Assume your golf scores are in any number of rows in column A. In column B, we want to pick up the 5 lowest scores. This can be written as follows, starting with B1 and copied down for as many low places you want to check:
=Small(A:A,row())
row() returns the current row that the formula is on (to start with, row 1, with B1).
Then on cell C1, simply sum these results, and that's all you need:
=SUM(B:B)

How to count current streak?

I have a list of 1s and 0s in excel ranging from A1:A74 and I am looking to work out what the current streak of 1's is.
For example I have:
1
0
1
1
1
I would want the streak to give me 3.
I have tried the following formula which seems to work for smaller ranges, but for my full set it gives me the wrong amount:
=COUNTA(A1:A73)-MATCH(1,INDEX(1/(A1:A73=0),0))
Any help would be much appreciated.
edit - I believe i've fixed the formula above to work:
=COUNTA(S$2:S$74)-MATCH(2, 1/(S2:S$74=0), 1)
This is basically finding the last position of 0 and minusing this from the overall number of rows which have values.
As Above, I've figured out the answer to my own question by just simplifying exactly what I needed to do and it became very obvious:
=COUNTA(S$2:S$74)-MATCH(2, 1/(S2:S$74=0), 1)
This is basically finding the last position of 0 and minusing this from the overall number of rows which have values.
If you can afford a helper column then there is another very easy way to do this.
Enter this formula in B2 (or any other cell in row 2(Assuming you are using a header)) and copy it down.
=IF(AND(A2=0,A3=0),B1+1,1)
You can then pick up the maximum value from this range and if required hide the column.

Resources