find the number of skip rows between records - excel

I have requirement to get row number of next matching value. ie.
Number 1 Number 2 Number 3 Number 4 Number 5 Number 6
16 33 28 20 23 14
13 12 27 29 2 32
31 25 9 28 17 10
11 22 14 3 18 13
12 39 22 32 25 24
37 40 33 18 9 3
4 35 17 24 7 12
16 3 38 8 17 24
now 16 is present in 7th row, and skipped rows are 6. 33 is present in 6th row so skipped rows are 5. Similarly 28 is present in 3rd row so skipped rows are 1.
output will be :
6 4 1 19 10 2
assume that 20 and 23 found in 20th and 11th row respectively.Skipped rows = row number of next find of that number - present row number.
I am not able to form formula for this. Match should work I guess, but not sure.

Put this formula in the first cell:
=AGGREGATE(15,6,ROW($A$3:$F$22)/($A$3:$F$22=A2),1) - ROW($A$3)
Then drag/copy across
If you want to drag down (put the results in columnar form):
=AGGREGATE(15,6,ROW($A$3:$F$22)/($A$3:$F$22=INDEX($2:$2,ROW(1:1))),1) - ROW($A$3)
Put it in the first cell and drag/copy down.

Related

Averages for range of values in excel

This is how my input looks like in excel,
days_took_to_equip
cumu_percent
1
0.017418302
2
0.020625735
3
0.023148307
4
0.025237133
5
0.026972115
6
0.028752754
7
0.030350763
8
0.032040087
9
0.033603853
10
0.035270349
11
0.036788458
12
0.037518976
13
0.038283738
14
0.039379516
15
0.040189935
16
0.040783481
17
0.041685215
18
0.042347247
19
0.043032109
20
0.043739798
21
0.044230616
22
0.04476709
23
0.045269322
24
0.045725896
25
0.046250956
26
0.046684701
27
0.047129861
28
0.047620678
29
0.047997352
30
0.048396854
Where my expected output is
Range
Avg cum Percent
1 to 10
0.027
1 to 20
0.033
1 to 30
0.038
Tried pivots tables and labelling is tricky here
I would need this out put to plot a graph
Try-
=MAP(SEQUENCE(3,1,10,10),LAMBDA(x,AVERAGE(INDEX(B2:B31,SEQUENCE(x)))))
I got three answers and the cells consists of formula
E3: =AVERAGE(INDEX($B$2:$B$31,SEQUENCE(RIGHT($D3,2))))
F3: =AVERAGE(INDEX($B$2:$B$31,ROW(INDIRECT("1:"&RIGHT($D3,2)))))
G3: =AVERAGE(OFFSET($A$1,1,1,RIGHT(D3,2)))

Counting combinations of values in table of values excel?

I have a table of values with each value in a different cell
e.g.
2 9 12 19 41 45 14 39
12 14 19 27 39 40 30 44
6 9 13 15 16 41 7 20
8 16 14 34 13 44 5 15
10 11 20 24 27 36 9 41
Is there a way to find which pairs of numbers are most common.
i.e.
13 & 15 appear 2 times
14 & 44 appear 2 times
24 & 27 appear 1 time
I was hoping for a formula as the table has over a hundred rows in it so would be time consuming to count manually.
The formula you would want would be the one for the row totals of a pair of numbers in A2 and B2:
=SUM(MMULT(--($E$2:$L$6=A2),TRANSPOSE(COLUMN(E:L))^0)*MMULT(--($E$2:$L$6=B2),TRANSPOSE(COLUMN(E:L))^0))
entered as an array formula using CtrlShiftEnter
There will be formulas for for listing distinct pairs up to a certain number out there - I used
=IF(ROW()=2,1,IF(B1<45,A1,A1+1))
for A2 and
=IF(B1<45,B1+1,2+COUNTIF(B$1:B1,45))
for B2.
If you scroll down this list you can see that 13,16 occurs twice as well as 13,15.
9,41 occurs three times.
Note - I am assuming the numbers are like lottery numbers and any one number can only occur once in a row. The formula could easily be modified to account for duplicates within a row.

Excel: Subtracting One Value from the Next Entry in Column

I have a set of data that has two columns, one for enumerating entries, and the second for storing a value:
1 0.000000000
2
3
4
5
6
7
8
9 0.664076596
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 0.668394223
The values in column 2 are separated by varying numbers of rows throughout my data sheet. I want to subtract each value (Value B) in column 2 by the previous value above it (Value A) (ie 0.664076596 - 0.000000000, and 0.668394223 - 0.664076596 etc.). I want to put these results in the third column and next to Value B. How would I do this in Excel?
Use this which will find the last number value in the column before the current row.
=IF(B2="","",IFERROR(B2-INDEX($B$1:B1,MATCH(1E+99,$B$1:B1)),B2))

How can I delete duplicates group 3 columns using two criteria (first two columns)?

That is my data set enter code here
Year created Week created SUM_New SUM_Closed SUM_Open
0 2018 1 17 0 82
1 2018 6 62 47 18
2 2018 6 62 47 18
3 2018 6 62 47 18
4 2018 6 62 47 18
In last three columns there is already the sum for the year and week. I need to get rid of duplicates so that the table contains unique values (for the example above):
Year created Week created SUM_New SUM_Closed SUM_Open
0 2018 1 17 0 82
4 2018 6 62 47 18
I tried to group data but it somehow works wrong and does what I need but just for one column.
df.groupby(['Year created', 'Week created']).size()
And output:
Year created Week created
2017 48 2
49 25
50 54
51 36
52 1
2018 1 17
2 50
3 37
But it is just one column and I don't know which one because even if I separate the data on three parts and do the same procedure for each part I get the same result (as above) for all.
I believe need drop_duplicates:
df = df.drop_duplicates(['Year created', 'Week created'])
print (df)
Year created Week created SUM_New SUM_Closed SUM_Open
0 2018 1 17 0 82
1 2018 6 62 47 18
df2 = df.drop_duplicates(['Year created', 'Week created', 'SUM_New', 'SUM_Closed'])
print(df2)
hope this helps.

calculate consecute streak in excel row

I am trying to calculate 2 values. Current Streak and Long Streak.
each record is on 1 row and contains a name and values
each of those columns has a value from 1 to 200.
Example:
John Doe 14 16 25 18 40 65 101 85 14 19 18 9 3
Jane Doe 24 22 18 5 8 22 17 17 15 2 1 5 22
Jim Doe 40 72 66 29 25 28
Jan Doe 27 82 22 17 18 9 6 7 9 13
For each row, I'm trying to find the "current" streak and "longest" streak.
The values have to be <= 24 to be counted. Data goes left to right.
John: Current 2; Long 5
Jane: Current 13; Long 13
Jim: Current 0; Long 0
Jan: Current 0; Long 8
What would be a formula to calculate the current and long in their own cell on that same row (would have to go before data)?
For current run, assuming data in C2:Z2, try this array formula:
=IFERROR(MATCH(TRUE,C2:Z2>24,0)-1,COUNT(C2:Z2))
Confirm with CTRL+SHIFT+ENTER
For longest streak try this version based on the cell references used in your comment
=MAX(FREQUENCY(IF(P7:BB7<=24,COLUMN(P7:BB7)),IF(P7:BB7>24,COLUMN(P7:B‌​B7))))
Again confirm with CTRL+SHIFT+ENTER
or to allow blanks in the range (which would end a streak) you can use this version
=MAX(FREQUENCY(IF(P7:BB7<>"",IF(P7:BB7<=24,COLUMN(P7:BB7))),IF((P7:BB7="")+(P7:BB7>24),COLUMN(P7:BB7))))

Resources