Excel sum formula over varying indices - excel

I'm trying to reproduce the sum of the values in column I within one cell, without having to evaluate them for each row individually. For better understanding see the following screenshot:
I've sifted through endless INDEX/INDIRECT/etc. results both here and on Google, but can't seem to figure it out... Basically I want to just sum over the row-wise evaluations of this formula:
=-MAX($B$1-MAX(A$1:A1)+MIN(A$1:A1),0)
Note that the starting row of each evaluation is fixed.
Edit: the solution proposed by Scott works if Excel recognizes the LET() function, which does not seem to be the case for my work laptop even though it has Office 365 Pro Plus, probably this latest insider program is not enabled.

With the dynamic array formula in Office 365:
=LET(seq,SEQUENCE(COUNT(A:A)),rng,OFFSET(A1,0,0,seq),SUMPRODUCT(-(B1-MAXIFS(rng,rng,"<>")+MINIFS(rng,rng,"<>"))*(B1-MAXIFS(rng,rng,"<>")+MINIFS(rng,rng,"<>")>0)))

Related

Standard Excel formula behaves differently depending on which version of Excel I use

I have what I think is a standard formula, which is behaving differently depending on which Excel version I use, Excel 365 or Excel 2019
=IF(F5=$M$1;IFERROR(IF(AND(IFERROR(FIND("CONV";B5;1);"NY");F5=$M$1);"KONV");IF(F5=$M$1;"NY";"ORG"));"ORG")
In the two screenshots below, Excel version 2019 is on top, and Excel version 365 is beneath it. In the first screenshot everything is the same, but in the 2nd picture, "NY" becomes an error in Excel 2019 (which is correct and what I want), but in Excel 365 I get a wrong TRUE.
My issue isn't to fix the formula so it works. Rather, I want to know why the difference between Excel 365 and Excel 2019 is there in the first place.
Interesting post. With the problem at hand being illogical, the explaination (or rather my hypothesis due to the lack of documentation) is actually the opposite. In short: Dynamic arrays are the culprit to the difference between ms365's and previous versions of handling each condition in the AND() function.
First, even though the ms-documentation tells us that all conditions need to evaluate to TRUE, the reality of it is that there are two other important rules for us to keep in mind:
Text values or empty cells supplied as arguments are ignored.
The AND function will return #VALUE if no logical values are found or created during evaluation.
Let's assume that with the below examples, the value NY is written in cell A1. In Excel 2019 and earlier versions, you should recieve the following results:
Formula
Outcome
=AND(TRUE)
TRUE
=AND(TRUE,A1)
TRUE
=AND(TRUE,"NY")
#VALUE
=AND(TRUE,{"NY"})
TRUE
=AND({"NY"})
#VALUE
Whether it's intentional or not, in versions prior to ms365 any text value will result in an error unless it's written in an array format or pulled in through a cell-reference.
I can only expect the difference with ms365 to be explained that the latter will automatically evaluate the single text-value as an array due to the mechanics of dynamic array functionality.

Error in formula on Excel 2010

Well, I tried to make a formula on Excel 2010 in order to get flexible results.
The idea is to count cell written less cells empty, so the formula should be: =CONTAR(C10:C69) - CONTAR.BLANCO(C10:C[VALUE])Where the Value is 8 + the result of CONTAR(C10:C69).
The real formula actually extends more than this, but I got stuck at this step.
That being said, how can I produce the same result using Visual Basic to actualize the list every time excel is modified?
Thanks in advance!
EDIT: thank you for the correction
The best way is to use Index to return a reference to the range from C10 to C[Value]
=COUNT(C10:C69)-COUNTBLANK(C10:INDEX(C:C,8+COUNT(C10:C69)))
(I hope I have got the correct equivalent functions for Contar etc.)

Concat/Concatenate Error

All, I come before you with a puzzle that I cannot figure out.
I recently transitioned to Office 365 from 2010 and am having a world of difficulty adapting my formulas and scripts to work in the new platform.
Particularly, I am running into an issue where one of my SUM(IF(CONCATENATE formulas can no longer find data.
Previously, in 2010, I had a formula as follows:
{=SUM(IF(CONCATENATE(B8,C8,D8)=CONCATENATE(ProjectData!A2:A20000,ProjectData!C2:C20000,ProjectData!W2:W20000),ProjectData!T2:T20000))}
This formula would sum a range of numbers if 3 cells matched 3 cells in a range of data.
This no longer works in Office 2016.
Has any syntax changed that might be causing this error? Thanks in advance.
Use SUMIFS()
=SUMIFS(ProjectData!T:T,ProjectData!A:A,B8,ProjectData!C:C,C8,ProjectData!W:W,D8)

SUMPRODUCT with INDIRECT

I have checked all question related to this topic, but none of it helped.
I have this formula
=SUMPRODUCT((INDIRECT("Ap"&ROW()&":"&"Ap"&(ROW()+$T4-1)));(INDIRECT("Ap"&ROW()&":"&"Ap"&(ROW()+$T4-1))))
This results in - 0.
=SUMPRODUCT((INDIRECT("Ap"&ROW()&":"&"Ap"&(ROW()+$T4-1)))*(INDIRECT("Ap"&ROW()&":"&"Ap"&(ROW()+$T4-1))))
This results in - "VALUE!
With SUM command everything worked fine, but I'm stuck with this now. I use Microsoft Office 2013 and I can't seem to find out the problems with this INDIRECT function, since it works nicely with other command.
For example, if I have in column A numbers from 1 to 5 in the first 5 rows, and the same in column B, I put the formula in C1
=SUMPRODUCT((INDIRECT("A"&ROW()&":"&"A"&(ROW()+4)))*(INDIRECT("B"&ROW()&":"&"B"&(ROW()+4))))
Results the same as the original example.
The construction you are using is quite poor, to be honest. Not only is the unqualified ROW() a very unrigorous choice, but volatile INDIRECT constructions can almost always be avoided in this type of set-up.
Much better is:
=SUMPRODUCT(INDEX(A:A,ROWS($1:1)):INDEX(A:A,ROWS($1:1)+4),INDEX(B:B,ROWS($1:1)):INDEX(B:B,ROWS($1:1)+4))
See here for a discussion on the advantages of using ROWS instead of ROW:
http://excelxor.com/2014/08/25/row-vs-rows-for-consecutive-integer-generation/
Regards
Using your example with data in columns A and B, and this answer on a similar question, the ROW() function returns an array, rather than a single value. Wrapping it in sum() solves this.
=SUMPRODUCT(INDIRECT("A"&SUM(ROW())&":"&"A"&SUM((ROW()+4))),INDIRECT("B"&SUM(ROW())&":"&"B"&SUM((ROW()+4))))

SUMIFS source code for excel 2003 AND the ability to calculate on columns

we are looking to find the original? source code for SUMIFS to use in out excel sheet (for both 2003 and 2007. Here is why:
2003 doest support the SUMIFS method
When we do have SUMIFS we cannot utilize formulas "around" the columns (like YEAR())
For example, we want to calculate the ANSWERS that match the YEAR value of the date in cell A1 with the date values in range L:L. Now this doesnt work because we cant use YEAR(L:L) and hence we need to make another column M:M with the YEAR values from L:L
Thus we need the source to be able to upgrade the code further
=SUMIFS(ANSWERS;L:L;"="&YEAR(A1)) <= This works
=SUMIFS(ANSWERS;YEAR(L:L);"="&YEAR(A1)) <= This doesnt
Many thanks
With referenc to these questions:
Replacing SUMIFS in Excel 2003
VBA code for SUMIFS?
I doubt that you'll find the original code, which is, I imagine, C++ and part of the Excel internals. If that's correct, then it wouldn't help much, even if Microsoft gave it to you!
In general, I recommend against using =SUMIF(), =SUMIFS() and other functions that take a string to define the condition for testing: apart from anything else, I'm concerned that they're going to be slow, since my best guess is that internally they construct a string for evaluation for each value. In XL2007 (all I have available right now) at least, this turns out not to be necessarily true (see comments below).
I'm generally much happier with array functions. This, for example, should work in both Excel 2003 & 2007:
=SUMPRODUCT(--(YEAR(L:L)=YEAR(A1)),ANSWERS)
This gets the same answer:
{=SUM(IF(YEAR(L:L)=YEAR(A1),ANSWERS,0))}
In the latter case, you'd enter the formula without the curly braces ({ & }) and confirm it using Control+Shift+Enter to tell Excel it's an array formula.
In the first example, we build a list of boolean results with YEAR(L:L)=YEAR(A1) and convert it into an array of 1s and 0s using the double-negative. Then SUMPRODUCT takes care of the rest. This version requires that ANSWERS has the same dimension as L:L, i.e. it should be the entire column (or the range in L should be constrained in size).
In the second, Excel will run through each entry in L:L. If its year matches that in A1 then the corresponding ANSWERS value will be used, otherwise zero. This formula seems to be more tolerant of dimension differences but I'd still be careful.

Resources