Sorting Logic - Excel formula - excel-formula

All, I am trying to do the following in Excel
Take 2 rows each time say leg 1 and leg 2, check which of the values in column ISO value comes first and populate column Alphabetical order with either 'First' or 'Second'
For eg: for the first 2 rows,110 comes before 150 so the values for alphabetical order will be First and Second.
I want to repeat the same logic for leg 3 and leg 4 and then for leg 1,leg2 and so on.
Any ideas how to achieve this using Excel functions (the table is sorted on leg number)?
**Leg Number ISO Value Alhpabetical order**
1 110 First
2 150 Second
3 110 First
4 150 Second
1 8 First
2 150 Second
3 8 First
4 150 Second
1 150 Second
2 74 First
3 150 Second
4 74 First
1 74 First
2 150 Second
3 174 Second
4 150 First

IF(ISODD(ROW()),IF(OR(B2=B1,B2< B1),"First","Second"),IF(ISEVEN(ROW()),IF(OR(B2=B3,B2< B3),"First","Second"))). Put this formula in Cell C2 and copy down as needed.

Related

Sumif of multiple Index matches against one value

Need help regarding Excel dynamically search based sum of two columns matching from two different tables.
I have got this Table of Data Entered One Time
A B C
1 Qlty Warp Weft
2 Stpl.1 150 20
3 Cotn.1 80 60
4 Stpl.2 20 20
5 Cotn.2 20 20
6 Stpl.3 20 40
in Column A2:A6, Quality can not be duplicated, its a unique Name
The Data entry and report Table is here
A B C D E F
8 Yarn Name Sent Bags Remaining Qualty Used Warp Used Weft
9 20 800 600 Stpl.1 71 200
10 150 101 30 Stpl.2 70 30
11 40 300 290 Stpl.3 100 10
12 20 400
C9:C5000 is Returning Column, Values are calculated on the base of Column A9:A5000 (Yarn Name)
Need to Find Yarn Name (eg:) "20" in B2:B6 AND/OR C2:C6, wherever it matches, index that Quality from A2:A6
Then match the returned qualities(could be more than one) to D9:D5000 and sum the mathced results from E9:F5000
I have tried so far in C12
=SUMIF($A$9:$A12,A12,$B$9:$B12)-(SUMIF($D$9:$D12,INDEX($A$2:$A$6,MATCH(A12,$B$2:$B$6,0)),$D$9:$D12)+SUMIF($D$9:$D12,INDEX($A$2:$A$6,MATCH(A12,$C$2:$C$6,0)),$D$9:$D12))
PS:- I am using Excel 2007
If I understand correctly, then following array formula can help you:
=SUM(IFERROR(INDEX($A$2:$A$6,N(IF(1,(MMULT(--($B$2:$C$6=A9),TRANSPOSE(COLUMN($B$2:$C$6)^0))>0)*(ROW($B$2:$C$6))-1)))=TRANSPOSE($D$9:$D$12),0)*TRANSPOSE($E$9:$E$12+$F$9:$F$12))
Array formula after editing is confirmed by pressing ctrl + shift + enter
Edit:
To calculate Warp and Weft columns separately use following array formula:
=SUM(IFERROR(INDEX($A$2:$A$6,N(IF(1,((A9=$B$2:$B$6)*ROW($B$2:$B$6))-1)))=TRANSPOSE($D$9:$D$12),0)*TRANSPOSE($E$9:$E$12))+SUM(IFERROR(INDEX($A$2:$A$6,N(IF(1,((A9=$C$2:$C$6)*ROW($C$2:$C$6))-1)))=TRANSPOSE($D$9:$D$12),0)*TRANSPOSE($F$9:$F$12))

Divide excel column to N equal groups

I have a column with ordinal values. I want to have another column that ranks them in equal groups (relatively to their value).
Example: If I have a score and I want to divide to 5 equal groups:
Score
100
90
80
70
60
50
40
30
20
10
What function do I use in the new column to get this eventually:
Score Group
100 5
90 5
80 4
70 4
60 3
50 3
40 2
30 2
20 1
10 1
Thanks! (I'm guessing the solution is somewhere in mod, row and count - but I couldn't find any good solution for this specific problem)
If you don't care about how the groups are split for groups that aren't evenly divisible, you can use this formula and drag down as far as necessary:
= FLOOR(5*(COUNTA(A:A)-COUNTA(INDEX(A:A,1):INDEX(A:A,ROW())))/COUNTA(A:A),1)+1
Possibly a more efficient solution exists, but this is the first way I thought to do it.
Obviously you'll have to change the references to the A column if you want it in a different column.
See below for working example.

excel incrementation by consecutive numbers

I have a form, thanks to user JamTay317, That lists data depending on folder number (bold number in form). I need to copy it for all 1500 folders (about 400 pages)
Form is divided on 4 labels on a page for easier printing
form overview
Form get it's folder number (nr teczki) from list with all folders from another sheet called "lista teczek":
list of folders
For first 4 folder numbers I use formula:
A2='lista teczek'!A1
J2='lista teczek'!A2
A21='lista teczek'!A3
J21='lista teczek'!A4
When I copy whole page underneath it increments by 36 (number of rows between)
A38='lista teczek'!A37
J38='lista teczek'!A38
A57='lista teczek'!A39
J38='lista teczek'!A40
Instead of A5, A6, etc.
Is there any way to override excel's incrementation to force it to use consecutive numbers? Or at least formula which will make it easier to follow folders list?
So I would use offset() to get the correct position
=A2=OFFSET('lista teczek'!$A$1;ROW(A1)-INT(ROW(A1)/36)*36+4*INT(ROW(A1)/36)-1;0)
So this will offset from A1 in the list sheet.
Below are row numbers a resultant lookup row numbers
Note the formula I used in the offset has an extra "-1" as this is an OFFSET so to get 1 from 1 we need to offset by 0
1 1
2 2
3 3
4 4
37 5
38 6
39 7
40 8
73 9
74 10
75 11
76 12
109 13
110 14
111 15
112 16
145 17
146 18
147 19
----LOGIC--- (edit)
So the idea is that you work out the occurrence you are on. Int(row()/36) gives us this. For example
int(1/36)=0
Int(363/36)=10
First part gives us the offset from the start of the occurrence
3-int(3/36)*36=3
378-Int(363/36)*36=3
Second part give the total of the previous occurrence
4*int(3/36)=0
4*Int(363/36)*36=40
So you need to change the 36 to the gap between the occurrences and the 4 to the length of occurrences Not sure if that helps to explain

Find SUBTOTAL of List at Specific Interval

In Excel, I need to find which row has total sum of next nearest 100 (minimum 100), next total sum must using next value to get total sum.
As example below, because row number will be use to VLOOKUP a data series only when the sum of value equal or minimum every 100.
Row Value Mapping
--- ------ -------
1 1
2 50
3 52 1 # (1+50+52=103) Row #3 in Data series return: David
4 72
5 55 2 # (72+55=127) Row #5 in Data series return: Alex
6 70
7 80 3 # (70+80=150) Row #7 in Data series return: Alicia
At mapping column where I will put VLOOKUP code.
In C2 as,
=IF(AND(SUM(INDEX(B:B, IFERROR(MATCH(1E+99, C$1:C1)+1, 1)):B2)>=100,SUM(INDEX(B:B, IFERROR(MATCH(1E+99, C$1:C1)+1, 1)):B1)<100),MAX(C$1:C1)+1,"")
        
Fill down as necessary.

increment odd or even numbers in excel/openoffice calc?

Im trying to increment in 1st column every even number by 1 and the 2nd column increment all odd numbers by 1.
what I manually have done so far:
48 4
4 49
49 4
4 50
50 4
2 51
51 2
2 52
52 2
2 53
as you can see in the 1st column every even number is incremented by 1 and in the 2nd column every odd number is incremented by 1. How can i do that automatically?
I mostly use open office calc, but I also have excel so either solution for both or one of them would be great!
You don't need code for this, it can be done using in-cell formulas.
When you want to increment all even numbers by one:
=ROUNDDOWN(A1 / 2, 0) * 2 + 1
When you want to increment all odd numbers by one:
=ROUNDUP(A1 / 2, 0) * 2
...where A1 is the name of the cell. Then just drag down the first row to extend the series into the entire column.

Resources