In excel, how to use an array formula to sum a range to offsets of itself, generating a new "sum" range? - excel

I'd like to use an array formula to sum a range to multiple offsets of itself: for example, given the following range: {3,4,5,6,7} (say in cells A1:A5), I'd like to get the range added to itself, say 4 times, but each addition is offset by one column. So the answer would be a range equal to {3, 3+4, 3+4+5, 3+4+5+6, 3+4+5+6+7, 4+5+6+7, 5+6+7, 6+7, 7}
Here is an example, offset by rows:
3
4 3
5 4 3
6 5 4 3
7 6 5 4 3
0 7 6 5 4
0 0 7 6 5
0 0 0 7 6
0 0 0 0 7
=
3
7
12
18
25
22
18
13
7

Put the following in your first desired cell:
=IF(ROW(1:1)< COUNT($1:$1)*2,SUM(INDEX($1:$1,IF(ROW(1:1)<COUNT($1:$1),1,ROW(1:1)-COUNT($1:$1)+1)):INDEX($1:$1,MIN(ROW(1:1),COUNT($1:$1)))),"")
Then copy down. As numbers are added or subtracted from the first row the answer will change to match. Just copy down sufficient rows to cover twice the greatest number of values in row 1.

Related

In Excel, is there an efficient way to sum overlapping Named Rangess?

In Microsoft Excel, I have a named (2D) range. For simplicity, let's assume it looks like this:
1
2
3
4
5
5
4
3
2
1
This represent a time series growth curve, where N number of these could kick off in any point in time. I'm looking for an efficient way to calculate what the cumulative sum of these at any point in time would be, given that N start at that point in time.
So for example, if one starts at time 0, and one at time 3, and two at time 7:
0
1
2
3
4
5
6
7
8
9
1
0
0
1
0
0
0
2
0
0
Then the cumulative total would be:
0
1
2
3
4
5
6
7
8
9
1
2
3
4
5
5
4
3
2
1
1
2
3
4
5
5
4
2
4
6
---
---
---
---
---
---
---
---
---
---
1
2
3
5
7
8
8
10
11
11
I'd like to write a formula that gets to that total without having to use those extra rows to sum over, but can't figure out how.
Use SUMPRODUCT and INDEX:
=SUMPRODUCT(INDEX($M$1:$V$1,(COLUMN()-COLUMN($A$1:A1)+1)),$A$2:A2)
The ranges are dynamic and increase as it is pulled over.
with versions that are not Office 365 we need to trick INDEX into accepting an array:
=SUMPRODUCT(INDEX($M$1:$V$1,N(IF({1},(COLUMN()-COLUMN($A$1:A1)+1)))),$A$2:A2)
This would then be confirmed with Ctrl-Shift-Enter to make it an array formula.

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.

How to Number Rows Every 1000

How can I autonumber for every 1000 rows? without using macros.
I am trying to divide/batch 100k records for every 1000. And i figured creating batches and autonumbering them is a start.
Row1
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
2 1
2 2
2 3
2 4
2 5
2 6
2 7
2 8
3 1
3 2
3 3
3 4
3 5
3 6
3 7
3 8
In A1 enter:
=ROUNDUP(ROW()/8,0)
and copy down. In B1 enter:
=MOD(ROW()-1,8)+1
and copy down:
You type the first and second rows as 1 and 2 and then highlighting them and dragging from the little square at the bottom right of the selection will autofill with sequential numbers (ie 1, 2, 3, 4). Once you get to 1000 you can copy and paste the whole column up to that point at the bottom. Pasting 99 times should provide you with what you are requesting. Cheers.
MOD(dividend, divisor)
https://support.google.com/docs/table/25273?hl=en
Use that function with 1000 as the divisor. That should work

how find unique value from Different column

A B ANSWER
1 1 1
3 3 3
1 2 1
2 4 2
4 4 4
5 5 5
6 6 6
i have used this function to get above answer "=IF(ISERROR(MATCH(A2:A8,$B$1:$B$8,0)),"",A2)"
but I need answer like this i have given below (suppose if you take value in A column "1"
Which is repeated only once in column B)
A B ANR
1 1 1
3 3 3
1 2 0
2 4 2
4 4 4
5 5 5
6 6 6
I've just wrapped your formula in a condition that returns 0 where the count of the A value from start to the current row is more than one:
=IF(COUNTIF(A$1:A2,A2)>1,0,IF(ISERROR(MATCH(A2:A8,$B$1:$B$8,0)),"",A2))
.
An alternative formula that gives the same results as above for the sample data provided but may (or may not) suit the additional requirements mentioned in a comment:
=IF(COUNTIF(A$2:A$10,A2)<=COUNTIF(B$2:B$10,A2),A2,IF(COUNTIF(A$2:A2,A2)>COUNTIF(B$2:B$10,A2),0,IF(COUNTIF(A$2:A$10,A2)>COUNTIF(B$2:B2,A2),A2,0)))

Dynamically determining range to apply formula/function in EXCEL

I need to determine the range to apply the Frequency function. Here's what the problem is. On the given sheet, I have subtotals for my data and there is a column which has "Stop" Values.
The data would look something like:
Route1
Order# Stop# Qty
001016 1 5
008912 1 5
062232 2 6
062232 3 2
069930 4 1
1000 4 3
1001 4 4
1001 5 8
1003 8 1
Route 1 Subtotal 6 35
Route2
Order# Stop# Qty
10065 1 5
10076 1 5
10077 2 6
10079 3 2
10087 4 1
10098 4 3
10109 4 4
10171 5 8
10175 8 1
Route 2 Subtotal 6 35
How do I write VBA code for calculating the distinct stop values. I need the distinct count of the stop#. Hence in the example above you can see that the total stops are 6 because 1 stop can have multiple orders and 1 route can have multiple orders/stop. Hope I am making sense here. Let me know how I would write my VBA code for this. Thanks for your help.
For the Stop Subtotal unique count, try this formula (adjust ranges as required):
=COUNT(1/FREQUENCY(B2:B10,B2:B10))

Resources