SUM function produces a #VALUE! error when using in array formula - excel

I have the following values in a sheet (in A1:G10) range:
1 1 1 1 1 1 1
2 2 2 2 2 2 2
3 3 3 3 3 3 3
4 4 4 4 4 4 4
5 5 5 5 5 5 5
6 6 6 6 6 6 6
7 7 7 7 7 7 7
8 8 8 8 8 8 8
9 9 9 9 9 9 9
10 10 10 10 10 10 10
I need to calculate the sum of differences of values between two rows in the array above when both rows are defined by row numbers, for example: sum of differences of values between 10-th and 1-st rows, between 9-th and 2-nd rows and so on. Row numbers I defined in J1:K10 range:
1 10
2 9
3 8
4 7
5 6
6 5
7 4
8 3
9 2
10 1
Then I selected L1:L10 range, and in the first cell of it I entered the following formula:
=SUM((OFFSET(A1,INDEX(K1:K10,ROW(K1:K10)-ROW(K1)+1)-1,0,1,7)-OFFSET(A1,INDEX(J1:J10,ROW(J1:J10)-ROW(J1)+1)-1,0,1,7)))
and then pressed CTRL+SHIFT+ENTER so the formula is enterd as an array formula. And the formula returned a #VALUE! error for each cell in the range.
I tried to evaluate the formula, and it evaluates correctly except the last step: SUM({9,9,9,9,9,9,9}) becomes a #VALUE!
Here is a screenshot of the sheet for clarity:
What I'm doing wrong? Please suggest.

use SUMPRODUCT in L1:
=SUMPRODUCT(INDEX($A$1:$G$10,J1,0)-INDEX($A$1:$G$10,K1,0))
and copy down.

Related

Excel - Shift starting column right by x

In excel I have a dataset. This represents how much stock of 2 products is sold in the first, second, third, etc... month of the product being on the shelves (starts in A1):
Month 1 2 3 4 5 6 7 8 9 10 11 12
Product 1 3 5 2 1 6 1 2 4 7 2 1 5
Product 2 2 1 5 6 2 8 2 1 2 3 4 9
However, the first product sales do not always occur in month 1. They occur in month X. Is there a way (not VBA or copy and paste) of shifting the entries right by 'x' so they align with the month.
Example for data above
Product 1 starts in month 2
Product 2 starts in month 5
Month 1 2 3 4 5 6 7 8 9 10 11 12
Product 1 0 3 5 2 1 6 1 2 4 7 2 1 5
Product 2 0 0 0 0 2 1 5 6 2 8 2 1 2 3 4 9
*0 not required (great if possible), but more for illustration
Thanks
I have created a simple example that does the same job. The shown formula is copied over the shown cells in the row of new data. (The number '2' in the formula refers to the column number of the starting data cell which is column B, hence 2.)

Excel: I want to remove duplicate values in same row and many columns

I want to delete duplicate values in same row and multiple column in excel... i want this
A B C D E F G H I J K RESULT
R1 8 0 1 8 1 5 8 1 9 5 5 80159
R2 7 8 7 7 4 5 0 7 6 8 9 78450689
R3 5 2 0 6 4 2 7 6 1 3 0 52064713
R4 4 3 5 0 7 2 5 3 2 4 8 4350728
If one has the Dynamic Array formula:
=CONCAT(UNIQUE(A1:K1,TRUE))
If not then the assumption is that 0 will never be in the first column and that the data is as you provided, one number per cell:
=MMULT(TRANSPOSE(MODE.MULT(IF(MATCH(A1:K1,A1:K1,0)=COLUMN(A1:K1),A1:K1*{1;1}))),TRANSPOSE(10^(COUNT(MODE.MULT(IF(MATCH(A1:K1,A1:K1,0)=COLUMN(A1:K1),A1:K1*{1;1})))-TRANSPOSE(ROW(INDEX($ZZ:$ZZ,1):INDEX($ZZ:$ZZ,COUNT(MODE.MULT(IF(MATCH(A1:K1,A1:K1,0)=COLUMN(A1:K1),A1:K1*{1;1})))))))))
Depending on ones version this may need to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.
If it is text or the numbers are more than one digit then vba will probably be needed.

Formula to transpose horizontal numeric data vertical in excel

My input data in column A
1
2
3
4
5
6
7
8
9
If I want the above in Column B C D like
1 2 3
4 5 6
7 8 9
Use INDEX with some math:
=INDEX($A:$A,(ROW($A1)-1)*3+COLUMN(A$1))
Put in B1 copy over 3 columns and down 3 rows.
The *3 is the number of columns desired.

count with multiple crieria

I am stuck with a problem. Lets say I have the following data in range A1:K4
row1 1 2 3 4 5 6 7 8 9 10
row2 2 3 4 5 6 7 8 9 10 11
row3 3 4 5 6 7 8 9 10 11 12
row4 3 5 6 7 8 9 10 11 12 13
And the following data in range N1:P4
1 2 3
2 3 4
3 4 5
11 12 13
I want formulas in range R1:R4
The desired output should be R1=1, R2=2, R3=3, R4=1
i am trying to evaluate first set of numbers 1 2 and 3 and check in every row from row1 to row4 and find out how many rows matched all 3 numbers and the put the value in cell R1.. continue this for all 4 sets of number. Can someone help me with a formula?
Thanks
You could use this formula in R1 copied down to R4
=SUMPRODUCT((MMULT(COUNTIF(OFFSET(B$1:K$4,ROW(B$1:K$4)-ROW(B$1),0,1),N1:P1),{1;1;1})=3)+0)
although I've cheated a bit, there, because {1;1;1} is variable based on the number of columns in N1:P1 (and so is the 3), so for a more generic version (which would allow N1:P1 to be any size row) you can use this "array formula"
=SUM((MMULT(COUNTIF(OFFSET(B$1:K$4,ROW(B$1:K$4)-ROW(B$1),0,1),N1:P1),TRANSPOSE(COLUMN(N1:P1)^0))=COLUMNS(N1:P1))+0)
confirmed with CTRL+SHIFT+ENTER

Data fill in specific pattern

I am trying to fill data in MS Excel. I am given following pattern:
1 2
1
1
2 5
2 5
2
3
3 6
3
4
4
5 4
And I want my output in following format:
1 2
1 2
1 2
2 5
2 5
2 5
3 6
3 6
3 6
4
4
5 4
I tried using if(b2,b2,c1) in column 3. but that doesn't solve the problem for a=3 and a=4.
Any idea how to do this in Excel?
With sorting thus:
(the effect of which in this case is merely to move 6 up once cell) and a blank row above:
=IF(AND(A2<>A1,B2=""),"",IF(B2<>"",B2,C1))
In C2 and copied down should get the result you ask for from the data sample provided.

Resources