Excel formula stop working after x number of rows
A similar question was posted 4 years ago. There were two answers. I have reviewed both. The first response is excellent but it is not the cause of my issues. The second answer was a statement that the person who responded had the same issue and what he or she did to solve it which will not work in my case. There was no explanation as to why the problem occurred.
Here is my problem. I am using the following formula:
IF(MONTH(MDB.xlsx!Date)=7,SUMIFS(MDB.xlsx!_910,MDB.xlsx!Activity,"MGRINC",MDB.xlsx!AcctNum,$Y202),0)
MDB is a Master Data Base. It currently has 214 rows but will grow substantially to probably around 5000 rows. The named ranges in the MDB are currently defined as rows 1 to 500. The above formula is in a spreadsheet, with about 300 rows. The formula works fine through row 201. From 202 on, it only returns zeros.
This is what I have done:
I have looked at constituent parts of the formula using F9, all values and arrays are reporting correctly. (That’s why the defined name range is currently set to only 500 rows, so I can breakdown a formula using F9 and not get an error after 8,192 characters.)
If I move the line with this formula from line 202 to an earlier row, it works fine.
If I delete earlier rows, the formula works fine.
This appears to be a memory issue of some sort but I don’t understand why. I have built larger and much more complex spreadsheets some of which take minutes to calculate with no issues.
Any thoughts?
Extracting the Month inside a Sumif will not work. You could add two conditions, one testing for the date being greater/equal to July 1, the second testing for the date being smaller/equal to July 31.
=SUMIFS(MDB.xlsx!_904,MDB.xlsx!Date,">="&date(2020,7,1),MDB.xlsx!Date,"<="&date(2020,7,31),MDB.xlsx!Activity,"MGRINC",MDB.xlsx!AcctNum,$Y202)
Or, you could add a column to your source data that has the month number, then test for that month number
Or, you could change the formula to use SumProduct instead of Sumif, incorporating the month filter into the SumProduct parameters like this:
=Sumproduct((MONTH(MDB.xlsx!Date)=7),--(MDB.xlsx!Activity="MGRINC"),--(MDB.xlsx!AcctNum=$Y202),MDB.xlsx!_910)
With the formula just testing form Month number, the year is disregarded, so if you have data spanning multiple years, you may want to add a parameter that checks the year.
Note that all these formulas are regular formulas and do not need to be array entered.
Related
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))
I have a spreadsheet tracking issues and have various columns related to each issue, including the date the issue was discovered (column C), the date the issue actually started (column P), the date the investigation was started (column L), and the date the investigation ended and the issue was resolved (column M). I want to track how long an investigation has been open, how long it takes to complete an investigation, the time the issue started till it was discovered, and how long an issue was open; for each aspect I want to track, I'm grouping the counts into ranges (i.e., issues open 30 days or less, issues open between 31 and 60 days, etc.).
I was able to get the count of open issues using this formula (this one is for the 31 to 60 day grouping): =COUNTIFS($M:$M,"",$L:$L,"<"&TODAY()-31,$L:$L,">="&TODAY()-60)
However, I haven't been able to figure out the formula for the other things I want to track. Here's one formula I tried for tracking completion time: =COUNTIFS($M:$M,"*",$L:$L,"<"&$M:$M-31,$L:$L,">="&$M:$M-60). This formula returns 0 and when looking at the Function Arguments window, I get a #VALUE! error for Criteria2 ("<"&$M:$M-31) and Criteria3 (">="&$M:$M-60).
I'm guessing the issue is the date I'm trying to use in the second formula is not a constant like TODAY() is in the first formula but my Google skills haven't been sufficient to find an answer. Any ideas?
You're right about criterias, COUNTIFS can't handle the criteria specified as an range. The SUMPRODUCT function should be used instead. Without seeing a sample, it is difficult to say exactly, but the problematic formula could be modified as follows:
=SUMPRODUCT(($L2:$L1000<$M2:$M1000-31)*($L2:$L1000>=$M2:$M1000-60))
Use the exact range, not the entire column. You can include empty cells, but not text (eg column names) or other non numeric data that may interfere with the calculation M-31 or M-60
I have excel data in the following format
Date Amount
01-Jan-16 23.94
12-Jan-16 17.96
26-Jan-16 32.92
03-Feb-16 38.90
20-Feb-16 62.27
26-Feb-16 45.89
I would like to sum the amount field for specific months, that is I would like to sum up the amount in January and also in February separately.
This is the code I have tried thus far which I found in a previously asked question (see Excel Formula to SUMIF date falls in particular month).
=SUM(IF(MONTH(A:A)=1,B:B,0))
It works for January but when I change 1 to 2 it returns zero.
=SUM(IF(MONTH(A:A)=2,B:B,0))
Would sumifs work better?
Here are two other ways of doing it:-
=SUMPRODUCT((MONTH(A2:A10)=1)*B2:B10)
and
=SUMIFS(B2:B10,A2:A10,">="&DATE(2016,1,1),A2:A10,"<"&DATE(2016,2,1))
Change as necessary to get totals for other months.
I have put the results next to the original array formula in this screen shot:-
Use specific range rather than full column. You must use the formula as array formula.
=SUM(IF(MONTH($A$2:$A$1000)=1,$B$2:$B$1000,0))
Press CTRL+SHIFT+ENTER to evaluate the formula as array formula.
I am somewhat new to writing large, complicated formulas with excel. I took over a report from someone about 7 months ago and it seems that every week I find issues with what was written with his formulas.
This week I am having issues with a match formula. We have a report we run for a big hardware store and they report based on weeks. This last week was 201501 (2015, week 1.) Last week was 201452 (2014, week 52.)
To look at 4 week sales averages, my predecessor setup 4 numbers that would change every week based on the week you type in one of the column headings. So, when I type 201452,
#1 is 201449
#2 is 201450
#3 is 201451
#4 is 201452
He feeds those into a match function.
I found this week that 201501 does not correctly display the weeks. I got
Results Formula Used
201501 =D1 (The cell where you type the Store's week)
201500 =IF(M1=201301,201252,IF(M1=201401,201352,M1-1))
201499 =IF(L1=201301,201252,IF(L1=201401,201352,L1-1))
201498 =IF(K1=201301,201252,IF(K1=201401,201352,K1-1))
I changed those formulas
Results New Formula
201501 =D1
201452 =IF(RIGHT(M1,2) = "01",(LEFT(M1,4) - 1)&"52",M1-1)
201451 =IF(RIGHT(L1,2) = "01",(LEFT(L1,4) - 1)&"52",L1-1)
201450 =IF(RIGHT(K1,2) = "01",(LEFT(K1,4) - 1)&"52",K1-1)
However, the match formulas he has setup throughout the workbook have not been fixed. They are still displaying "#N/A." One such formula is
=INDEX(N5:DZ5,1,MATCH(Data!$L$1,$N$1:$ED$1,0))
This formula basically looks at the column headers, and if it sees that the column header matches the week I've typed, will display the value within that range.
Basically, any formula that's being fed the 201452 value is returning "#N/A". The other numbers miraculously display data.
I've already tried converting all of my data in the affected rows to "General" format type. I've tried checking to see if I have spaces before or after in all of my formulas and column headers, but am still having no luck.
Any ideas?
After trying and trying and trying, I found that Excel does not like the concatenation. Trim does not help, Text does not help, Concatenate of course did not work.
I ended up realizing I could simply write
=IF(RIGHT(M1,2) = "01",M1-49,M1-1)
This makes it so that in the instance where the number to the right of it is the first week, subtract 49 days and produce 52 instead of 00.
I'm guessing here, but it could be that your formulas are presenting the Year/Week combo as a number, where the Match formula is looking for text (for Excel's purpose, it doesn't recognize them as the same).
You can get around this, by wrapping your formulas above with the text formula
So you'd have the following:
Results New Formula
201501 =TEXT(D1,"0")
201452 =TEXT(IF(RIGHT(M1,2) = "01",(LEFT(M1,4) - 1)&"52",M1-1),"0")
201451 =TEXT(IF(RIGHT(L1,2) = "01",(LEFT(L1,4) - 1)&"52",L1-1),"0")
201450 =TEXT(IF(RIGHT(K1,2) = "01",(LEFT(K1,4) - 1)&"52",K1-1),"0")
I would need some help again with another excel countif expression. I have the line i2:al2 which contains leftover stock data.I am building a worksheet to calculate remaining stocks in % as per supervisor's wish.
As I am working with %, for example if I say that 90% sales that means we have 103 stock left and with 91% sales I have 100 stock left.
Anyways I got around to count the number of stock left in line i2:a12 using countifs.
Example if I need to calculate leftover stock for sales at 90% which means leftover stock level of 100 to 102. I have used :
=countif(range,">100")-countif(range,">102")
This method seems to work till I reach negative numbers, i.e. oversales. For example, if I try to do the following:
=countif(range,"-100")-countif(range,">0")
the formula seems to stop working. If I count manually using a conditional formatting I get a totally different answer for the oversales.
Maybe I am getting the logic of the countif function wrong. My purpose for the expressison is:
=count(in range, values >=X & <=Y)
As I have only access to excel 2003 I cannot use Countifs method. Anyone could help me on this issue?
Many thanks.
You can use an array formula:
=SUM((range>=x)*(range<=y))
For that to work, you need to press CTRL-SHIFT-ENTER for that to use array formula.
Alternatively, using what simoco gives in the comment works too without having to save as array formula.