Excel Formula across worksheets: If a=x, b=y then c=z - excel

I started off using
=IF(AND(A1="this",B1="that"),"x","")
=IF(AND('[Employee Emails.xlsx]Alpha Order'!$A$2=A2,'[Employee Emails.xlsx]Alpha Order'!$B$2=B2, ???? > THEN I want it to pull the next cell '[Employee Emails.xlsx]Alpha Order'!$C$2 into C2. So C2 would display the email address.
Hopefully if firstname & lastname match, then it pulls the email address into the new cell. Otherwise I have to manually look them up & copy & paste into the new workbook.

I think this is what you want:
=IF(AND('[Employee Emails.xlsx]Alpha Order'!$A$2=A2,'[Employee Emails.xlsx]Alpha Order'!$B$2=B2), '[Employee Emails.xlsx]Alpha Order'!$C$2,"")
Though you may also want to look into VLOOKUP and INDEX/MATCH

If this were your data:
A B C D E F G
1 A G 1 A G
2 B H 2 C I
3 C I 3 D K
4 D K 4
5 E L 5
6 F M 6
In G1 you'd need this array formula (applied with Ctrl+Shift+Enter):
=INDEX($D$1:$D$6,MATCH(F1&G1,$B$1:$B$6&$C$1:$C$6,0))
And it would produce this:
A B C D E F G
1 A G 1 A G 1
2 B H 2 C I 3
3 C I 3 D K 4
4 D K 4
5 E L 5
6 F M 6
Hopefully you'll find this helpful.

Related

Matrix and match

I have a dataset in excel, like this and I need to do a match for doing the matrix but I don't know how to do, I can't order (my real dataset it's more complicated than this)
I would like to have an array that multiplies data that are similar to each other. In this case A = A and aa = aa as a condition to then make the final matrix, ideas?
I have used match but it does not execute the function correctly
Try using SUMPRODUCT() Function --> Simply multiplies arrays together and returns the sum of products.
• Formula used in cell K2
=SUM(($A2=$G$2:$G$5)*($B2=$H$2:$H$5)*(C2*$I$2:$I$5))
And Fill Down & Fill Right !!!
Try this:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
Condition 1
Condition 2
Condition 1 & Condition 2
Machine 1
Machine 2
Machine 3
Index 1
Index 2
Index 1 & Index 2
Timeprod
Machine 1
Machine 2
Machine 3
A
aa
=A2&B2
0,2
1
0
B
aa
=H2&I2
0,5
=VLOOKUP($C2,$J:$K,2,FALSE)*D2
=VLOOKUP($C2,$J:$K,2,FALSE)*E2
=VLOOKUP($C2,$J:$K,2,FALSE)*F2
B
aa
=A3&B3
1
2
0
D
bb
=H3&I3
1
=VLOOKUP($C3,$J:$K,2,FALSE)*D3
=VLOOKUP($C3,$J:$K,2,FALSE)*E3
=VLOOKUP($C3,$J:$K,2,FALSE)*F3
C
bb
=A4&B4
0
0
0
C
bb
=H4&I4
2
=VLOOKUP($C4,$J:$K,2,FALSE)*D4
=VLOOKUP($C4,$J:$K,2,FALSE)*E4
=VLOOKUP($C4,$J:$K,2,FALSE)*F4
D
bb
=A5&B5
0
0
6
A
aa
=H5&I5
0,2
=VLOOKUP($C5,$J:$K,2,FALSE)*D5
=VLOOKUP($C5,$J:$K,2,FALSE)*E5
=VLOOKUP($C5,$J:$K,2,FALSE)*F5

How can I duplicate a row and append it directly after the duplicated row using pandas?

I've been trying to figure this problem for a couple of hours now and seem to reach a dead end everytime. A small example of what I want to do is shown below.
Normal Series
a
b
c
d
Duplicated Series
a
a
b
b
c
c
d
d
Try with loc and df.index.repeat:
>>> df.loc[df.index.repeat(2)]
Normal Series
0 a
0 a
1 b
1 b
2 c
2 c
3 d
3 d
>>>
Or with reset_index:
>>> df.loc[df.index.repeat(2)].reset_index(drop=True)
Normal Series
0 a
1 a
2 b
3 b
4 c
5 c
6 d
7 d
>>>
You can just concat a duplicated series together and sort it.
sample = pd.Series(['a','b','c','d'])
output = pd.concat([sample,sample]).sort_values().reset_index(drop=True)
output

SUM based on list of categories

Consider the following Excel
A B C D
1 foo 7 whaa
2 bar 5 AA
3 baz 9 BB
4 bal 1 AA
5 oof 3 blah
6 aba 9 C
Extra:
Each row has either a value in column C OR in column D
The values in column Care categories (in this example ÀA,BB,C`)
The values in column Dcan be anything
I need a SUM (based on column A) as follows:
SUM of column B for all lines that have a value in (any value) in column D (called Rest)
SUM of column B for each category in column C. I have a list of the categories (see below)
So like this:
A B
1 Rest 10 <----- 7 + 3
2 AA 6 <----- 5 + 1
3 BB 9
4 C 9
What formulas do I need in column B above to get this result?
or, you can use sumproduct to solve:
H2=SUMPRODUCT(($D$4:$D$9=IF(G2="Rest","",G2))*$C$4:$C$9)
H2=SUMIF($D$4:$D$9,IF(G2="Rest","",G2),$C$4:$C$9)

Transpose data in Excel

My table currently looks like this:
1 a b c d e
2 a
3 b d g h
4 a c
5 d e j
My desired format is this:
1 a
1 b
1 c
1 d
1 e
2 a
3 b
3 d
3 g
3 h
4 a
4 c
5 d
5 e
5 j
Is there a way to make this modification in Microsoft Excel? I have attempted this in Ms Access but there is a column limit (225) which I exceed. In addition, I have attempted to use the TRANSPOSE function in Excel, but this only switches rows to columns. Please provide suggestions on how this transformation might be achieved. Thanks!

Excel Conditionally SUM rows totals

I have an excel like this:
I want to sum the totals by when (month), type and if it's in the budget. For example I want a result like this:
So... it "search" for every when with the same month, multiply the ammount but "in budget" column, and in sums everything by type that matches that.
I hope I explained well!! I think the result image will help!
Thanks a lot in advance!!
If you are prepared to generate another column (here: F) into your workbook like
A B C D E F
1 when curr type amnt budg
2 2 U F 85 1 F21
3 2 U T 50 1 T21
4 2 U T 150 1 T21
5 2 U T 380 1 T21
6 3 U G 600 1 G31
7 3 Y G 250 1 G31
8 6 U T 600 1 T61
9 9 U T 500 0 T90
[F2] = C2 & A2 & E2
[F3] = C3 & A3 & E3
...
Then you can do the sums with:
[A12] = sumif($F$2:$F$9, "F21", $A$2:$A$9) ' for when=2, type="F" and "in budget"
[A13] = sumif($F$2:$F$9, "T21", $A$2:$A$9) ' for when=2, type="T" and "in budget"
...

Resources