Excel - Perform Summation of Column of If Statements In One Cell - arrays

I feel like I've done this before but am at a total loss after looking at a lot of pages already.
Consider a set of data given in two columns, x and y. X column is always ascending in value, y is random. I need a single cell to calculate the sum of a column of IF statements within a specified range of x without actually displaying the column of IF statements or using VBA. In other words: I want to turn this (IMG1) into this (IMG2)
In the first picture, the z column has this formula for each cell in a descending order: =IF(AND(B2>0,A2>$D$2,A2<$D$3),A2-A1,0)
I feel like I can use SUMIFS or an array formula somehow but I'm at a loss.
Please forgive if I improperly posted this somehow - this is my first post.
-Adam

Try this Array Formula which requires a special key stroke Ctrl+Shift+Enter instead of Enter alone.
=SUM(IFERROR((A2:A11>0)*(B2:B11>0)*(A2:A11>D2)*(A2:A11<D3)*(A2:A11-A1:A10),0))
Confirm this formula with Ctrl+Shift+Enter

Related

How do I use an array formula to sum a range of columns?

I'm trying to figure out how to use array formulas in Excel 365. Here's a very simple situation I'm starting with. I have an array of values, and I want to get the sum of the values in each row. In reality, I have 2000 rows, and 600 columns, but to simplify let's say I just have the following:
I want to put the sums in the 3rd column (just 6, 60, 600) using an array formula. I know I can just enter a simple formula for one row and copy it down, but I'm interested in seeing how this is done with an array formula so I can just enter a single formula. What I want to do will get more complicated after that, but I want to start with this.
(I'm an experienced Excel user, but I haven't worked much with array formulas in Excel 365.)
Use BYROW/LAMBDA:
=BYROW(C2:E4,LAMBDA(a,SUM(a)))
Another option is MMULT
=MMULT(C2:E4,SEQUENCE(COLUMNS(C2:E4),,1,0))

How can I drag down to multiple rows a formula which has more than 1 row in its result?

I have an extension I am getting the data from, and I am referring to that extension in a formula with result of pre determined rows but I want more than 1 row in its result and that's when I have this problem, because I want to drag the formula to multiple rows but they overlap each other, for example if I wanted 3 rows in the result of the formula starting in row 1 and then drag it down from row 1 to row 3 the formula in row 1 and 2 will show an error because they're overlapped in each other I will put a picture in how it looks...
Is there a way to specify amount of rows as a space between each formula in a way that when I drag the formula down to more rows it will adjust to the "space" I specified?
This is the formula I am using, I am also referring to another sheet as you can see so it'll be great if you can use this formula to answer my question, if I can specify the "space" using another formula that is (also it's probably obvious but the pre determined rows in the formula is the "2d").
=CRYPTOFINANCE("KRAKEN:"&'crypto-track'!C4&"/USD", "price_history", "2d")
this is usually solved by constructing an array of formulae where you stack them up in the line like:
={CRYPTOFINANCE("KRAKEN:"&'crypto-track'!C4&"/USD", "price_history", "2d");
CRYPTOFINANCE("KRAKEN:"&'crypto-track'!C5&"/USD", "price_history", "2d");
CRYPTOFINANCE("KRAKEN:"&'crypto-track'!C6&"/USD", "price_history", "2d")}
this way the 2nd fx will pick up right after 1 fx ends
you can ease your pain of a "hand job" from constructing such an array - especially if that array needs to span over the larger range - by building a formula to generate a formula. for example: https://stackoverflow.com/a/68278101/5632629
also, make sure you obey the law of array constructs and successfully avoid all array errors - https://stackoverflow.com/a/58042211/5632629

Excel: contingent upon column, increment a different column and multiply all sums

So I have column A with mpnths. Column B has percent win and loss. I want to add 1 to the value in column B and then find the product of all values in column B to determine the compound growth of the dataset. Then I want to take this value and put in in my reports sheet.
=PRODUCT(SUM(1,IF(MONTH('#MOMO Trades'!A1:A1000)=4,'#MOMO Trades'!B:B,0)))
Please help me correct this formula.
thanks!
In order for the SUM function to add 1 to each row individually, you will need to use an array formula, rather than a formula. Otherwise, it will try to add 1 to an array, which it can't do.
To do this, enter the formula as you would normally, but when you have typed it press Ctrl+Shift+Enter instead of just Enter. It will show up surrounded by braces, like this:
{=PRODUCT(SUM(1,IF(MONTH('#MOMO Trades'!A1:A1000)=4,'#MOMO Trades'!B:B,0)))}

SUM with IF conditions for cells containing both strings and numbers

I've got a bigger table with one column that I want to focus on, containing designation and a number. I want to simply sum the numbers that meet the criteria based on a designation.
For the simplification, I made an exercising sheet (on the pic) where I split second column into two - one string and one numeric. Since my file is quite large with many columns that would need this it would be inconvenient.
In the left column it's easy to solve the problem, it could be even easier with simple SUMIF function, but an array SUM(IF... function is, at least I think, only viable option here.
So I solved the first table with array function, but what confuses me is how to modulate the TRUE statement. Simple replacement of C:C
with
VALUE(MID(F:F;4;4))
which would format my cells to get the numbers from string does not work that way - returns zero in E12 field. F12 is just application of string to number for last cell, F10.
THIS formula does not work, even adapting to different versions of the tool.
I could use VB but if possible anyhow I would like to avoid it since parts will be shared on mobile phones.
Any ideas? Thanks a lot!
Left table was split, right original format
The array formula which you used can be replaced by the SumIf formula like below...
=SUMIF(B:B,"B",C:C)
Also without the helper column, you can use the Sumproduct formula to achieve the desired output.
But don't refer the whole column in the formula like in the above SumIf formula.
Try this..
=SUMPRODUCT((B1:B10="B")*MID(F1:F10,FIND(",",F1:F10)+1,255)*1)
Change the ranges as per your requirement but remember to make them equal in size.

Sumproduct formula returns a #VALUE! error when the last array refers to a column with formulas in every row. MS Excel 2010

I am trying to find an easy way to calculate commissions off of sales on multiple sheets within a workbook. Each month, I need to find the total net profit for only items sold within the specified month.
The formula I am currently using is:
=SUMPRODUCT((TEXT('Sheet Name'!$P$3:P24,"MY")=TEXT($G$4,"MY"))*'Sheet Name'!$M$3:M24)
Column P shows the Sold Date,
Column M includes a formula in each row to calculate the net profit, and
cell G4 is where I would enter the month & year I am currently working with.
I have come to the conclusion that it only gives me the #VALUE! error because of the formula in each row of Column M (example: =IF(OR(F15=0,G15=0)," ",(F15-L15)) ).
When I reference a different column (in place of Column M) that does not contain formulas it works perfectly (example: =SUMPRODUCT((TEXT('Sheet Name'!$P$3:P24,"MY")=TEXT($G$4,"MY"))*'Sheet Name'!$G$3:G24) ). Also, changing the astrisk to a comma causes the formula to calculate incorrectly and add the (--(TEXT double negative does not fix the problem.
How to I get this array to calculate without removing the formulas from Column M?
Thanks for your attention.
I presume it is giving you a #VALUE error because your formula results in text (a space) and it errors when trying to multiply a space by a number (aka True or False). I think you would be better served changing your M column formula to =IF(OR(F15=0,G15=0),0,(F15-L15)). Do you have a specific reason to not make it evaluate to 0? Also is there a reason you are converting to text to do your month/year check?
Try something like this: =SUMPRODUCT(--(MONTH('Sheet Name'!$P$3:P24)=MONTH($G$4)),--(YEAR('Sheet Name'!$P$3:P24)=YEAR($G$4)),'Sheet Name'!$M$3:M24). Of course this is dependent on entering the dates as actual dates. The -- is used to change a logical/boolean (true/false) into a 1 or 0. It won't do anything useful to text. For example, it should also work as =SUMPRODUCT((MONTH('Sheet Name'!$P$3:P24)=MONTH($G$4))*(YEAR('Sheet Name'!$P$3:P24)=YEAR($G$4))*'Sheet Name'!$M$3:M24) since the multiplication converts the truthy statements to numbers. The trick is to make sure when everything else evaluates, you have =sumproduct(numbers,numbers,numbers). Your instance is one array of =sumproduct(numbers/text).

Resources