Copy cells to new row - excel

I have three columns, A, B and D
Column A and B have integer numbers that Im trying to map to column D which looks something like this:
A
B
C
D
1
3
7
2
4
9
I want to populate column C with column D's data, but I need to look like bellow:
A
B
C
D
1
3
7
7
2
4
7
9
3
3
7
4
4
7
5
3
7
1
4
9
2
3
9
3
4
9
4
3
9
5
4
9
I need to map column D and duplicate those numbers down to Column A and have Column C change every time Column A repeats to the first number, which in this case is 1

Related

Trouble Changing csv row based on column values in python3 and pandas

I am having issues trying to modify a value if columnA contains lets say 0,2,12,44,75,81 (looking at 33 different numerical values in columnA. If columnA contains 1 of the 33 vaules defined, i need to then change the same row of colulmnB to "approved".
I have tried this:
df[(df.columnA == '0|2|12|44|75|81')][df.columnB] = 'approved'
I get an error that there are none of index are in the columns but, i know that isn't correct looking at my csv file data. I must be searching wrong or using the wrong syntax.
As others have said, if you need the value in column A to match exactly with a value in the list, then you can use .isin. If you need a partial match, then you can convert to string dtypes and use .contains.
setup:
nums_to_match = [0,2,9]
df
A B
0 6 e
1 1 f
2 3 b
3 6 g
4 6 i
5 0 f
6 9 a
7 6 i
8 6 a
9 2 h
Exact match:
df.loc[df.A.isin(nums_to_match),'B']='approved'
df:
A B
0 6 e
1 1 f
2 3 b
3 6 g
4 6 i
5 0 approved
6 9 approved
7 6 i
8 6 a
9 2 approved
partial match:
nums_to_match_str = list(map(str,nums_to_match))
df['A']=df['A'].astype(str)
df.loc[df.A.str.contains('|'.join(nums_to_match_str),case=False,na=False),'B']='approved'
df
A B
0 1 h
1 4 c
2 6 i
3 7 d
4 3 d
5 9 approved
6 5 i
7 1 c
8 0 approved
9 5 d

Excel: find row in a table by condition

I have two tables with same column names, but different data.
Table1:
A B C D
1 3 4 5 OK
2 6 7 8
3 9 8 7
Table2:
A B C D
1 9 8 7
2 1 2 8
3 3 4 5
I want to write formula in D of Table2, which would copy D-column values by row values from Table1. (I want to find same row in other table and set D-column value for it).
I could use SUMIFS(Table1!$D:$D, Table1!$A:$A, "="&A1, Table1!$B:$B, "="&B1, Table1!$C:$C, "="&C1), but all the rows are unique and I have string value in $D:$D - I don't need SUM exactly, I need only one string value.
Is there any function to find column value by row condition?
The result I want:
A B C D
1 9 8 7
2 1 2 8
3 3 4 5 OK

Using IF and AND function

I am trying to use the IF and AND function in excel for values in two different cells. I have 25 conditions.
Below is the formula I've created but it keeps on saying there's an error.
IF(AND(A10=“A”,B10=1),11,IF(AND(A=“A”,B10=2),16,IF(AND(A10=“A”,B10=3),20,IF(AND(A10=“A”,B10=4),23,IF(AND(A10=“A”,B10=5),25,IF(AND(A10=“B”,B10=1),7,IF(AND(A10=“B”,B10=2),12,IF(AND(A10=“B”,B10=3),17,IF(AND(A10=“B”,B10=4),21,IF(AND(A10=“B”,B10=5),24,IF(AND(A10=“C”,B10=1),4,IF(AND(A10=“C”,B10=2),8,IF(AND(A10=“C”,B10=3),13,IF(AND(A10=“C”,B10=4),18,IF(AND(A10=“C”,B10=5),22,IF(AND(A10=“D”,B10=1),2,IF(AND(A10=“D”,B10=2),5,IF(AND(A10=“D”,B10=3),9,IF(AND(A10=“D”,B10=4),14,IF(AND(A10=“D”,B10=5),19,IF(AND(A10=“E”,B10=1),1,IF(AND(A10=“E”,B10=2),3,IF(AND(A10=“E”,B10=3),6,IF(AND(A10=“E”,B10=4),10,15))))))))))))))))))))))))))))))))))))))))))))))))
I expected the output to be, for example; if cell1 is "A" and cell2 is 1 the result should be 11.
I would highly advise a lookup table. Simply have all of your options listed out with their desired results and find them with a criteria search, such as the use of sumifs function.
For example, if you paste J1:L25 your possibilities:
A 1 11
A 2 16
A 3 20
A 4 23
A 5 25
B 1 7
B 2 12
B 3 17
B 4 21
B 5 24
C 1 4
C 2 8
C 3 13
C 4 18
C 5 22
D 1 2
D 2 5
D 3 9
D 4 14
D 5 19
E 1 1
E 2 3
E 3 6
E 4 10
E 5 15
You can then place the formula =SUMIFS($L$1:$L$25,$J$1:$J$25,$A$10,$K$1:$K$25,$B$10) to return your desired value.
That is, =SUMIFS(range_of_results, criteria_range_of_A-E, A10, criteria_range_of_1-5, B10)

Sum Column that matches a given criteria in Excel

How would I sum vertically the columns that meet a given criteria?
For example:
A B C D E F G
1 2 3 4 5 6 7
1 2 3 4 5 6 7
1 2 3 4 5 6 7
1 2 3 4 5 6 7
If criteria = A, then the formula would give me 4
if B, 8
if C, 12. I would like the criteria input to be a reference-able cell.
Thanks for your help!
Use INDEX to return the correct array. Use MATCH to return the correct column:
=SUM(INDEX(2:5,0,MATCH(J1,1:1,0)))
Assuming you have a sheet like this:
=SUM(INDEX($BF$5:$BI$16,,Match($BC$5,$BF$4:$BI$4,0)))

OpenOffice Calc Compare 2 cols and print col if true

I have two cols in Calc and want to compare both and print in col if it's a duplicate. Example:
A B C
1 2
2 2 2
3 3 3
4 5
5 6
6 7
7 7 7
8 8 8
9 9 9
What is the formula I need to print in col c to get this?
The formula to use in column C, to test if columns A and B are equals
=IF(A1=B1;B1;"")

Resources