Excel - How to get last the average of the last 10 values in a row which consist of a random mix of numbers and "N/A" - excel

So i have a row of numbers which is consistently added to, which may be like 4,N/A,N/A,5,5,6,7,4,N/A,N/A,N/A,5,N/A and I need a formula which is able to calculate the average of the last 10 numbers in the row.
I have tried
=AVERAGE(OFFSET(C7,0,COUNT(C7:X7)-MIN(10,COUNT(C7:X7)),1,MIN(10,COUNT(C7:X7))))

Use:
=AVERAGE(INDEX(1:1,AGGREGATE(14,7,COLUMN(1:1)/(ISNUMBER(1:1)),MIN(10,COUNT(1:1)))):INDEX(1:1,AGGREGATE(14,7,COLUMN(1:1)/(ISNUMBER(1:1)),1)))

Related

Excel - counting how many consecutive 0s in a row

I have multiple ‘people’ in rows in excel, with 10+ columns of system usage data. I want the final column to show how many consecutive months have 0 usage. For example, person a might have had 0 usage in March and April, used in June, then 0 usage in July - December, I would need the end column to show 6.
If your data is from B2 to M2 you could use the following formula:
=MAX(FREQUENCY(IF(B2:M2=0,COLUMN(B2:M2)),IF(B2:M2<>0,COLUMN(B2:M2))))
This will show the max number of consecutive 0's in that row 2 from column B to M.
Older versions of Excel require this array formula entered with ctrl+shift+enter
If you want the formula to show the quantity of consecutive zeroes of the last occurance in the row then you could use:
=LOOKUP(2,1/(FREQUENCY(IF($B2:$M2=0,COLUMN($B2:$M2)),IF($B2:$M2<>0,COLUMN($B2:$M2)))>0),FREQUENCY(IF($B2:$M2=0,COLUMN($B2:$M2)),IF($B2:$M2<>0,COLUMN($B2:$M2))))
I've made something for you, based on the numbers of the months in the year: 1-12 (in column "item").
In the "Value" column, there are the values zero or else.
The "Length" column contains the number of subsequent zeroes, based on following formulas:
First entry : =IF(B2=0,1,0)
Following entries: =IF(B3=0,C2+1,0)
Screenshot:
Have fun!
This might help if 2 is threshold for consecutive in F3:AI3
=SUM((FREQUENCY(IF(F3:AI3>=0,COLUMN(F3:AI3)),IF(F3:AI3<0,COLUMN(F3:AI3)))>=2)*1)
suppose I want count of values more than 10 in groups of 5 and more then
=SUM((FREQUENCY(IF(F3:AI3>=10,COLUMN(F3:AI3)),IF(F3:AI3<10,COLUMN(F3:AI3)))>=5)*1)
hope this helps

How to add 5 cells consecutively after an interval of 5 cells in a row of 200 cells?

I have a row of 200 cells. I have to add/average first five cells (A:E), and then take a break of 5 cells and then add/average second five cells (K:O) and so on till the end of the row. How can I do this?
I have tried doing it manually. Actually, I can do this manually but wanted to know if I can do this automatically.
I did a test making some faking data like this:
It's just a bunch of numbers from A1 to CB1. 80 numbers in total. 5 first numbers are 1, then next 5 are 2, next 5 numbers are again 1, then next 5 numbers are again 2, and so on.
This mean that there are 80 numbers, where 40 are 1 and 40 are 2. I want to get the average of first five cells (A:E), and then take a break of 5 cells and then average second five cells (K:O) and so on till the end of the row. In other words, I want to get the average of the 40 cells that contains a 1 value, and it should return a 1.
For this, I've used an array formula:
=AVERAGE(IF(VALUE(RIGHT(COLUMN(A1:CB1);1))<6;IF(VALUE(RIGHT(COLUMN(A1:CB1);1))>0;A1:CB1)))
NOTE: Because this is an array formula, it must be inserted pressing ENTER+CTRL+SHIFT instead of
only ENTER, or it won't work!
How this works?
You want to sum/average only values that are in columns where last digit of column number is 1 to 5, this means columns 1,2,3,4,5,11,12,13,14,15,21,22,23,24,25, and so on. So this works this way:
The part that says COLUMN(A1:CB1) will get an array of column numbers.
RIGHT(COLUMN(A1:CB1);1) will get last digit of each column number, but as text
VALUE(RIGHT(COLUMN(A1:CB1);1)) will convert that last digit into a number.
Then with both IFS, we get an array of only those values where last digit of column number is >0 and <6, and we get the average. I get as result of my average 1 and it's true, because the average of 40 times 1 is equal to 1.
Hope this works for you. You can adapt this easily to make it work with 200 cells.
For example:
In A2 put:
=IF(MOD(COLUMN(),10)=1,AVERAGE(INDEX(1:1,,COLUMN()):INDEX(1:1,,COLUMN()+4)),"")
Drag right.
You can use SUMPRODUCT to add the amounts in the columns and divide by 100:
=SUMPRODUCT(--ISEVEN(INT((COLUMN(A1:GR1)-1)/5)),A1:GR1)/100
if you do not always have 200 numbers you can make the 100 more dynamic with another SUMPRODUCT:
=SUMPRODUCT(--ISEVEN(INT((COLUMN(A1:GR1)-1)/5)),A1:GR1)/SUMPRODUCT(ISEVEN(INT((COLUMN(A1:GR1)-1)/5))*(ISNUMBER(A1:GR1)))
this function have CTRL+SHift+Enter and drag this function until your last data IF(OR((RIGHT(COLUMN(A5),1)+0)={1,2,3,4,5}),A5,--FALSE)
You Find The Columns only which end (1,2,3,4,5) , in last. You use Sum function For Add.

Excel - function to find the highest sum in a table using each row and column only once

I've got a table in excel with 10 rows and 10 columns.
The table contains 100 different values between 1 and 3.
I want to find the highest sum of 10 values using only 1 value from each row and 1 from each column.
Do u guys know a function that finds the highest sum? - I've tried to do i manually, but there are to many combinations!
Hope it makes sense.
Thanks in advance:)
My solution builds on what I wrote in the comment, i.e. you first take the maximum value in the 10x10 array, then the maximum in the 9x9 array (excluding the row/column of the first maximum), etc. My solution tries not to do everything in one formula, but I add a few helper columns, and a bit more helper rows (it is fast and dirty, but it works and is easily audited/understandable). You always can do this on a separate worksheet which you could hide if needed.
The screenshot above goes from cell A1 till Y31.
The key formulas:
3.55 is the result of =MAX(B2:K11)
The first gray cell is =IFNA(MATCH($M12;B2:B11;0);""), and you drag this 9 cells to the left. This tries to find a match with the max result in each column of the table;
The 10 left of the 3.55 is =MATCH(TRUE;INDEX(ISNUMBER(P12:Y12);0);0) , and gives the column number of the max value.
The 2 next to the 10 is =INDEX(P12:Y12;N12) and gives the row number of the max value.
The 1 in cell B12 is =IF(OR(B$1=$N12;$A12=$O12);0;1), and creates a 10x10 matrix with a row and column with zeroes where the previous max value was found.
Then you multiply this with the preceding matrix and create a new 10x10 matrix below (enter {=B2:K11*B12:K21} array formula (ctrl+shift+enter) in B22-K31
You then copy/paste rows 12 till 31 9 times below
The 23.02 is the total sum =SUM($M$12:$M$211) from all 10 maximum values and is the result you are looking for. The 10 is just a check with =COUNT($M$12:$M$211)

All combinations of 4 out of 7 columns with totals using excel

I have 7 columns to choose from and I need to pick 4 of those columns and generate a total for each row. I also need every combination of 4, which means I'll have 35 new columns with the totals for each of those combinations showing in each row. I need the code for this and if it can be done only using Excel. Here is an image of the columns and the grayed ones are the 7 columns I'm talking about. My knowledge of Excel is very limited. There are over 1,500 rows if that matters.
multi step approach that is going to use some helper rows. there may be a more elegant formula that will do this, and much slicker options in VBA, but this is a formula only approach.
Step 1 - Generate List of Column Combination
To generate the list 4 helper rows will need to be insert at the top of your data. either above or below you header row. These 4 rows will represent the column number you are going to pick. To keep the math simpler for me I just assumed the 1 for the first column and 7 for the last column. those numbers will get converted to later to account for column in between in your spreadsheet. For the sake of this example The first combination sum will occur in column AO and the first helper row will be row 1. The first combination will be hard coded and it will seed the pattern for the remainder of column combinations. Enter the following values in the corresponding cells:
AO1 = 1
AO2 = 2
AO3 = 3
AO4 = 4
In the adjacent column a formula will be placed and copied to the right. It will automatically augment the bottom value by 1 until it hits its maximum value at which point the value in the row above will increase by 1 and the the value of the current will be 1 more than the cell above. This will produce a pattern that covers all 35 combinations by the time column BW is reached. Place the formulas below in the appropriate cell and copy to the right:
AP1
=IF(AO2=5,AO1+1,AO1)
AP2
=IF(AO2=5,AP1+1,IF(AO3=6,AO2+1,AO2))
AP3
=IF(AO3=6,AP2+1,IF(AO4=7,AO3+1,AO3))
AP4
=IF(AO4=7,AP3+1,AO4+1)
Step2 - Sum The Appropriate Columns
I was hoping to use a some sort of array type operation to read through the column reference numbers above, but I could not get my head around it. Since it was just 4 entries to worry about I simply added each reference manually in a SUM function. Now the important thing to note is that we will be using the INDEX function over the 13 columns that cover the range of your columns so to convert the index number we figured out above, to something that will work to grab every second row, the number that was calculated will be multiplied by 2 and then 1 will be subtracted. That means 1,2,3,4 for the first column combination becomes 1,3,5,7. You can see this in the following formula. Place the following formula in the appropriate cell and copy down and to the right as needed.
AO5
=INDEX($AB5:$AN5,AO$1*2-1)+INDEX($AB5:$AN5,AO$2*2-1)+INDEX($AB5:$AN5,AO$3*2-1)+INDEX($AB5:$AN5,AO$4*2-1)
pay careful attention to the $ which will lock row or column reference and prevent them from changing as the formula is copied.
Now you may need to adjust the cell references to match your sheet.

sum assigned vlaues if sum for each value meets a specific criterion

in excel, I have two columns. one containing months of the year (in numbers) each month number occurring in different number of rows, and in the second column I have a duration of time for each row (in hours and minutes).
now I want to do the following job with an excel function in just one cell (the same job could be done using a table with 12 cells, each for one month but I want to pack it all in one cell):
1- for each month number, sum all cells in the second column (time) which have that month number in the adjacent cell (this could be done with a sumif )
2- if that sum is more than 4 hours then return one for that month else return zero (this step could be done with a formula like this: IF(R10>(--"4:00");1;"") )
3. in the end the numbers assigned to each month summed together.
thanks to everyone who helps
the picture below, shows the steps:
enter image description here
Try,
=SUM(--(SUMIFS(Table1[time],Table1[month],{1,2,3,4,5,6,7,8,9,10,11,12})>TIME(4,0,0)))

Resources