Locking an Excel formula - excel-formula

I am tracking travel times and part of that is 10-day averages. So I have the formula: =sum(a4:a13)/count(a4:a13) - and then a5:a14, a6:15, etc.
When I create new rows at the top, I find that my calculations have changed to =a4:a4 (11 rows).
What I think I need to do is =sum(a"row":a"row+10")/count(a"row":a"row+10")
I suspect this will turn out to be easy, but my Google searching ability has failed me so I'm hoping someone can help or point me to an existing answer.
Thank you!

Use INDEX:
The following will give you a static A4:A13:
=SUM(INDEX(A:A,4):INDEX(A:A,13))
You can do the same in the COUNT.
To make it more dynamic you can use Row and some math:
=SUM(INDEX(A:A,ROW()):INDEX(A:A,ROW()+10))
This will reference the row in which the formula is found and create a range that is from that row to a row 10 cells down.

Related

Use VLOOKUP as criteria inside COUNTIFS

After years of using this community, I have a question that I can't find an answer to. I hope you all can help!
I am trying to get a count of the number of "Grounded" items that each individual is overdue for. My screenshot (Count Tracker) shows a very condensed version of what I'm working with. Columns A-C is my large (15,000 rows) data field that is imported from an external source. In columns G-H I have listed each possible task (about 100 rows) and the type (Grounded and Non-Grounding plus many others). Column F is where I am trying to get the count.
My formula in F9 currently uses COUNTIFS to get a count of the instances in the large array that equal E9 ("Smith" in this case) and where the due date in the large array is less than or equal to the current date in F8. What I can't figure out is how to also add to count the Tasks in the large array where the task type in Column H equals "Grounded". I tried VLOOKUP, but it seems it doesn't like it and tells me there is a problem with the formula. It doesn't work, but here's the general idea of what I'm after:
=COUNTIFS($A$2:$A$7,$E9,$C$2:$C$7,"<="&$F$8,VLOOKUP($B$2:$B$7,$G$2:$H$4,2,FALSE),"=Grounded")
With how the data is currently presented, Smith should have a count of 1 and Jones should have a count of 0. I have a feeling that this is more simple than I'm making it to be, but I can't figure it out. I am using Excel 2016.
Hopefully I explained the problem well enough. Thank you for your assistance.
With Excel 2016 I'd say MMULT() is a good alternative here:
CSE-Formula in F9:
=SUM((A$2:A$7=E9)*(MMULT((TRANSPOSE(G$2:G$4)=B$2:B$7)*(TRANSPOSE(H$2:H$4)="Grounding"),ROW(G$2:G$4)^0))*(C$2:C$7<=F$8))
You could add a fourth column that stores whether that Task is Grounded
The formula for D2 would then be:
=INDEX($H$2:$H$4,MATCH(B2,$G$2:$G$4,0))
Modify your CountIfs formula to use this new column as a criteria
=COUNTIFS($A$2:$A$7,$E9,$C$2:$C$7,"<="&$F$8,$D$2:$D$7, "Grounded")
Try this Sumproduct+Vlookup formula without helper solution, and can work for your Excel 2016
In F9, formula copied down :
=SUMPRODUCT((A$2:A$7=E9)*(VLOOKUP(T(IF({1},$B$2:$B$7)),G$2:H$4,2,0)="Grounded")*($C$2:$C$7<=$F$8))

Using Excel Formulas to return the count of non zero in a column

I spent half the day racking my brain and playing around with the formulas i know of in the excel world but I still cannot figure out a method to do this without using VBA coding. Hopefully someone out here would be able to help provide some guidance without the use of code.
The scenario is this and refers to the screenshot above:
Objective: Determine the number of non zero values in a particular month's column for every row that has an "exceptions" label.
The month is controlled by the user input cell.
Example:
Total number of non zeros in Feb column is 6.
Actual result that I am expecting: 3 (because there are three rows with "exceptions" label and we should count the total of those rows only.)
I've tried Index/Match/Countifs/lookups but just cannot find the right combination.
Closest I came to was using the screenshot below but that only returns the total number of non zeros in that table.
Just putting the question out there for any of the excel gurus to help.
Appreciate the time and thanks in advance!
Regards,
Stan
If you do not want volatile functions like offset or indirect, you can still do it with index (your formula isn't wrong at all). Just try this:
=COUNTIFS(INDEX(F2:K7,,MATCH(G10,F1:K1,0)),">0",E2:E7,"exeptions")

Counting Cells in a Range that Contains Formulas, Only when a Date is Returned?

Frequent browser, first time poster. Please go easy:
I have spent the last few days searching online, and on here for a solution to a problem I have encountered for the first time. I have a report that pulls from multiple worksheets. One column is a formula that does a VLOOKUP to another sheet and pulls back a date, if it exists. I then have a cell at the top of the sheet that calculates how many dates are pulled back out of all of the rows (to calculate % complete). This is where I am having the problem. I have tried variations of COUNTIF, COUNTA, COUNTBLANK, and so on, and formulas trying to reverse calculate,
=SUM(C4)-COUNTIF(Table3[2014 Process Date],"")
At first it appeared to work, but in this example, I had 1949 rows, and dates only populated in 7 of those rows. In theory it should return 7. Instead it is returning 237. I have done multiple filters, and manually reviewed the data in the column, and only 7 dates are there. The column has the VLOOKUP in and IFERROR nest,
=IFERROR(VLOOKUP(A12,Table_TaxData.accdb3[#All],240,FALSE),"").
I am guessing I am overlooking something silly, and was hoping someone would be able to help steer me in the right direction, or let me know what I am missing. Thanks in advance for any help!
Wow, looks like I need some more coffee! Thank you, I guess I assumed that it would be much more complicated than that. I just threw in
=COUNT(Table3[2014 Process Date])
And it worked like a charm! Thanks again!
If I'm reading your formula correctly, the target cells hold either the DATE, or a blank "".
If so, you can do a COUNTIF and do this:
=COUNT(B:B)
to get # of dates.
or
=COUNTA(B:B)-COUNT(B:B)
to get # of blanks.
(I used column B, not sure where your final values are in you're looking for - adjust accordingly)

How to outline the range of several columns and tabs in 3D formula?

After a lot of searching I succeed making a formula with a reference to another tab (March) > =SUMIF(maart!$Z7:$Z47,"410200",maart!$W7:$W47) ... :)
Nevertheless I need some help ...
1) How to adjust the formula (as concise as possible) to search for multiple columns? So not only $W7:$W47 but also $X7:$X47 and $Y7:$Y47 in the same month.
2) How to adjust the formula to search on multiple tabs? From januari!:december!
Thanks in advance!
[edit]
I know now how to put 2 (12) months into a formula:
=SUMIF(maart!$Z7:$Z47,"410200",maart!$W7:$W47)+SUMIF(april!$Z7:$Z47,"410200",april!$W7:$W47)
... but it is surely possible to shorten such a long string, isn't it?
For multiple sheets have a look at my answer here
....but for multiple columns I think you would have to repeat the formula (criteria and sum ranges are always the same size in SUMIF)
If you want to generate "sheetlist" automatically in the formula then for all 12 months you can use an expression like
=TEXT({1,2,3,4,5,6,7,8,9,10,11,12}*29,"MMMM")
You might have to change "MMMM" depending on your regional settings

Using a Variable in Excel for COUNTIF

First time question and I hope it's easier than I'm making this.
Can I use a variable inside a COUNTIF formula?
Currently my formula is:
=COUNTIF($C$2:$C$415,R6)
I would like to have $415 as my variable. I have tried something along the lines of:
D1=415=COUNTIF($C$2:$C$(D1),R6) ..
but obviously get a error.
The reason I need this is column C will constantly be incrementing as I add more rows.
Instead of going into each of my formulas and updated 415 to 416, 417 etc, I would like to just define a Cell that can be my variable, or total rows.
Currently Column C can have blank cells, so I can't have a macro that finds the next empty cell.. but I do however have Column A with a constant populated cell and stops at the last ticket. However Column A is unrelated to the COUNTIF.
UPDATE 1
I'd also like to mention that I'd be using this variable in many formulas in the spreadsheet. Not only COUNTIF's. Also, the COUNTIF contains text.
UPDATE 2
Actually, I figured it out! I am using this formula instead:
=COUNTIF(INDIRECT("C"&D1&":A"&D2),R6)
I'm putting D1=2 and D2=415 and will just update cell D2 with how many rows I have.
I guess I just needed to ask the question thoroughly to fully understand what I wanted!
Thank you in advance for all help, tips and suggestions.
Would "=COUNTIF($C:$C,R6)" do the trick? This will apply COUNTIF to the whole of column C. It's an easy solution, but probably not the most efficient.
I prefer tables for storing data; as new data is added, the table automatically expands and the columns are already labeled (much like Named Ranges). Then you can have =COUNTIF(Table1[Column1],"Criteria"), which will encompass any new rows added to the table automatically. Especially helpful if you have multiple tables in the same column.

Resources