Dynamic SUM or SUMIF Formula - excel

I want to get the SUM of the first column IF the next column has data. In this example, the second column has data for the first 6 rows, therefore the sum that I want to get is the sum of the first 6 numbers in column 1. How the second column gets its data is chronological, so there will be no skipped cells.

You could use this formula:
=SUMIFS(A:A,B:B,">0")
It will sum the numbers in the first column, if the corresponding letters in the second column are greater than zero. Let me know if this does not cover all of your criteria, I'm sure I can help.
Thanks.

Related

Sum the result of every 2 rows, if the result is negative

I have a single column of numbers, I need to sum row 1 and row 2, sum row 3 and row 4, all the way to the end of column. And then, I need to sum all the previous result if the result is negative only.
I can only do this series of adding without creating more columns because I have to to this for many columns and I don't want to create another column to store the sub result as that will double the number of columns.
Any way I can achieve this with excel formula? Thanks.
In B2, formula copied down :
=IFERROR(1/(1/SUM(OFFSET($A$1,(ROW(A1)-1)*2+1,0,2))),"")
Edit #.1
In A10, enter formula :
=SUMPRODUCT(0+TEXT((A2:A8*MOD(ROW(A2:A8)-1,2))+(A3:A9*MOD(ROW(A2:A8)-1,2)),"\0;-0"))
another SUMPRODUCT version:
=SUMPRODUCT(--TEXT(ISEVEN(ROW(A2:A8))*(A2:A8+A3:A9),"\0;-0;0"))

Excel formula to calculate the sum of the first n% visible rows in a filtered column

As I stated in the title, I want to calculate the sum of the first n% rows in a filtered column. The total numbers of rows in the column varies due to the filtering options, so my formula must work with different values of n.
For example :
In column A, I have 10 rows that contain values from 10 to 1 ( I sorted them from largest to smallest ).
In column B, I have 10 corresponding rows that contain 2 names: 4 of them contain the value "Tom", six of them contain the value "Jerry". When I filter the whole table and select only the rows that contain the value "Jerry", I want to be able to calculate the sum of the first 20% of the corresponding 6 number values.
This could work without any filtering if you want.
With criteria for column B in E1 and percentage you looking for in F1 with the assumption we want to round up the percentage to integers.
So formula in D1:
=SUMPRODUCT(LARGE((B2:B11=E1)*(A2:A11),ROW(A1:INDEX($A:$A,ROUNDUP(COUNTIF(B2:B11,E1)*F1,0)))))
So, without your data, I came up with this, edit to suit your situation...
So, based on the comment, I did a second version:
The helper column in col C is used with sumproduct to give the result...
You can use the percentile function in AGGREGATE with SUMIFS to do what you want:
=SUMIFS(A:A,B:B,"Jerry",A:A,">="&AGGREGATE(16,7,A1:A10/(B1:B10="Jerry"),0.8))
If you want to use the filter to do the decision:
=SUMPRODUCT(SUBTOTAL(3,OFFSET(A1,ROW(A2:A10)-1,,1))*(A2:A10>=AGGREGATE(16,7,A2:A10,0.8)),A2:A10)

Averaging difference of two consective rows in column 3 and doing this after every 5 columns Excel

I want to find the average values of difference of two consective rows (like C2-c1). Also i want to repeat this operation after every fifth column. Technically
repeat for every fifth column( average (succeeding row- preceeding row)). average value should be represented in another row or column.
In column D use the formula,
=IF(MOD(ROW(),5)=0,C2-C1,"")
This would give the difference for every 5th row. Then use the below formula to find average,
=AVERAGE(D:D)
Note:- since the formula contains ROW() function, you have to start from row 1 for the formula to work. If not alter the formula accordingly

Increment by 2 for n rows, increment by 4 once and repeat when referencing data from one sheet to another

thank you for taking the time to look at this question.
I'm looking for an equation that can easily take the numerical values from Sheet 1 (the first picture) which has 2 blank cells in between values for four values and then has 4 blank cells and then the other four values. I'm not sure if I am making sense but hopefully the picture I have attached helps.
Notice 2 blank rows between first 4 rows with values (Rows 2-11) and same between rows 16 and 25.
Also notice the 4 blank rows between the two sets of values.
For me, this is repeated for 700 values, same set up of 2 blank rows for 4 sets of values and then 4 blank rows and then four sets of values with 2 blank rows. I'm sure there is an easier way to do this.
I'm trying to recreate Sheet 2 from Sheet 1 using an equation. Is this possible?
Apologies in advance, English isn't my first language.
If the numbers are going to start in B2 and the intervals and offset staggers are static then,
=INDEX(B:B, 2+(ROW(1:1)-1)*3+INT((ROW(1:1)-1)/4)*2)
If the first number is in S6 then,
=INDEX(S:S, 6+(ROW(1:1)-1)*3+INT((ROW(1:1)-1)/4)*2)
Put this in D2:
=IFERROR(INDEX(Sheet1!B:B,AGGREGATE(15,6,ROW(Sheet1!$B$2:INDEX(Sheet1!B:B,MATCH("ZZZ",Sheet1!A:A)))/(Sheet1!$B$2:INDEX(Sheet1!B:B,MATCH("ZZZ",Sheet1!A:A))<>""),ROW(1:1))),"")
And copy down till you get blanks.
This will return the numbers in order that they appear on sheet 1.
The Sheet1!$B$2:INDEX(Sheet1!B:B,MATCH("ZZZ",Sheet1!A:A)) set the data set bounds. This being an array type formula it needs to reference the smallest possible data set. This part finds the last cell in Column A and sets that as the extent of the data set so we do not do unnecessary iterations.
The MATCH part will return the last row that has text in it, if Column A has numbers then we need to change the "ZZZ" to 1E+99 to get the last row in column A with a number.
The AGGREGATE is working like a small in that it will create an array of row numbers and Errors. It will return ROW Numbers where (Sheet1!$B$2:INDEX(Sheet1!B:B,MATCH("ZZZ",Sheet1!A:A))<>"") return true. And an Error where it returns FALSE.
The second criterion 6 in Aggregate tells it to ignore the errors, so it is only looking at the returned row numbers.
The ROW(1:1) is a counter. As the formula is dragged down it will iterate to 2 then 3 and so on. This tells the Aggregate that you want the 1st then the 2nd then the 3rd and so on.
The chosen row number is then passed to the INDEX and the correct value is returned.
If your numbers are in order (smallest to largest like your example) or you want the output in order(smallest to largest) then you can use this simple equation in D2:
=IFERROR(SMALL(Sheet1!B:B,ROW(1:1)),"")
Then copy down till you get blanks.
Here is another formula you might use.
=INDIRECT(ADDRESS((INT((ROW()-ROW($A$2))/4)*14+ROW(A$2))+(MOD(ROW()-ROW($A$2),4)*3),COLUMN($A$2),1,1,"Sheet1"))
You can paste it to the first cell where you want the result and copy down.
Note that $A$2 is the cell from where all the counting starts. If your data start from A3 you can change the references accordingly. Note further that ROW($A$2) is long for 2. I chose this syntax to enable you to identify the meaning.
COLUMN($A$2), on the other hand, just identifies Column A as the source of the data to be lifted. Row 2 in this formula is insignificant. It's the A that counts. However, COLUMN($A$2) is long for just 1, meaning column No. 1, meaning A. Once you get your bearing in the formula you can replace COLUMN($A$2) with 1.

If, Then, Duplicate Excel Formula

Column "A" is a numbering column for each Row, some numbers are the same, ie..
A1 is 1
A2 is 3
A3 is 1
A4 is 3
I need a formula that will show how many cells with content are in this column without counting duplicates, as above would be 2. I was figuring an "If-Then" formula but am unable to get it straight. Any help out there? Thank you in advance!
If you're using Excel 2013, I want to say that there's a count distinct function. Nonetheless, you can do it like this:
=SUM(IF(FREQUENCY(A1:A4,A1:A4)>0,1))
EDIT: Adding an explanation. The FREQUENCY function gets the frequency of the unique values within the array A1:A4 (first parameter), binning it using the values within A1:A4 (second parameter). The IF checks to see if that returns anything, i.e. if the frequency is greater than 0, in which case it returns 1 for each unique value it finds. Then the SUM adds the number of 1s returned by the IF statement, in turn giving you the number of unique values within the array A1:A4.

Resources