remove mismatched rows in excel - excel

I am having an excel file with 2000 records containing few columns like
A B C D E
114 5 270 product1 118
117 3 150 product1 190
118 9 300 product2 114
190 6 110 product1
191 11 540 product3
what I want to do is I want to remove the rows that are not matching the column A with E.
Expected Output
A B C D E
114 5 270 product1 114
118 9 300 product2 118
190 6 110 product1 190
Please help me

Assumption: your data table is in Sheet1, your Expected Output Table is in Sheet2.
Steps:
Copy column E of data table (DT) to column A of Expected Output Table (EOT).
Sort col A of EOT ascendingly (e.g. Data Ribbon > Sort & Filter).
Formula in B1 (EOT):
=Index(Sheet1!B$1:B$5, Match(Sheet2!$A1, Sheet1!$A$1:$A$5, 0), 1)
Above formula goes into the columns B to D in EOT.
Formula in E1 (EOT):
=$A1
The Index/Match would work even better if you had column headers. Then it would not matter whether the info from col B (DT) also goes into col B in EOT. Anyways, remember to adjust the ranges to your actual ones, and be careful with the $ signs.

Related

Create two new Dataframes from existing one based on unique and repeated values of a column

colA colB
A 125
B 546
C 4586
D 547
A 869
B 789
A 258
E 123
I want to create two new dataframe and the first one should be based on the unique values in 'colA' and the second one should be the repeated values of 'colB'. The colB has no repeated values. The first output is like this:
ColA colB
A 125
B 546
C 4586
D 547
E 123
The second output is like this:
colA colB
A 869
B 789
A 258
For the first group, use drop_duplicates. For second group, use duplicated:
print (df.drop_duplicates("colA"))
colA colB
0 A 125
1 B 546
2 C 4586
3 D 547
7 E 123
print (df[df.duplicated("colA")])
colA colB
4 A 869
5 B 789
6 A 258

Change array of SUMIF in case criteria exists in two different columns

A B C D E F
1 Results List A List B
2 Campaign Sales Campaign Sales Campaign Sales
3 Campaign_A 1.510 Campaign_A 500 Campaign_B 50
4 Campaign_B 120 Campaign_A 450 Campaign_B 40
5 Campaign_C 90 Campaign_A 560 Campaign_B 30
6 Campaign_D 1.650 Campaign_B 700 Campaign_C 80
7 Campaign_E 100 Campaign_B 710 Campaign_C 10
8 Campaing_F 70 Campaign_C 200 Campaign_F 70
9 Campaing_D 850
10 Campaing_D 800
11 Campaing_E 100
12 Campaing_F 320
13 Campaing_F 360
14 Campaing_F 290
15
16
The Excel table above consists of:
List A = Column C:D
List B = Column E:F
In each list campaigns can appear mutliple times.
In Column A:B I want to sum up the sales per campaign from the two lists using the SUMIF formula:
=SUMIF(C:C,A3,D:D)
=SUMIF(E:E,A3,F:F)
However, the List B should be prioritized over List A which means in case a campaign exists in List B (Column E) the SUMIF function should be only applied to List B and List A should be totally ignored.
The formula might look something like htis:
IF campaign exists in Column E then SUMIF(E:E,A3,F:F) else SUMIF(C:C,A3,D:D)
How can I achieve the desired results in Column B?
Or,
=IF(COUNTIF(E:E,A3)>0,SUMIF(E:E,A3,F:F),SUMIF(C:C,A3,D:D))
I would try with the following:
if(sumIf(E:E,A3,F:F)>0;sumIf(E:E,A3,F:F);sumIf(C:C,A3,D:D))

Line up Column B and its Value in Column C with Column A values retaining original order of column A. Puts non-matching column B values below

Please can anyone help out me doing this?
I have two main columns A and B. Column A contains a product code and column B contain its price. Now I have some product code in column C. I need their prices and maintain column C order.
A B C D
110 $10 115
111 $12 120
112 $18 117
113 $13 111
114 $22
115 $24
116 $98
117 $26
118 $77
119 $34
120 $17
Enter the formula in Column D and drag it down,
=IFERROR(INDEX(B:B,MATCH(C1,A:A,0),1),"")

Combining data tables

I have two data tables, similar to the ones below:
table1
index value
a 6352
a 67
a 43
b 7765
b 53
c 243
c 7
c 543
table 2
index value
a 425
a 6
b 532
b 125
b 89
b 664
c 314
I would like to combine the data in one table as in the table bellow using the index values. The order is important, so the first batch of values under one index in the common table must be from the table 1
index value
a 6352
a 67
a 43
a 425
a 6
b 7765
b 53
b 532
b 125
b 89
b 664
c 243
c 7
c 543
c 314
I tried to do it using VBA but I'm sadly a complete novice and I was wondering if someone has any pointers how to approach to write the code?
Copy the values of the second table (without the headers) under the values of the first table, select the two resultant columns and sort them by index.
Hope it works!

Compare column A with column B and return minimum value in column A in Column C

Here is my table. I want to return the minimum value from column A in column C only if the values in Column B are equal.
A B C
1 Price Category Lowest Price Per Category
2 240 19
3 231 19 231
4 233 19
5 450 12
6 438 12
7 425 12 425
8 674 33
9 675 33
10 671 33 671
You could try the SUBTOTALfunction and use this formula in the column for lowest:
=IF(A2=SUBTOTAL(5;$A$2:$A$4);A2;"")
You would have to manually adjust the locked range ($A$2:$A$4) for every group though so that it matches the range for the group.
Or if your happy with getting the min value for each group on a separate row under every group you could just mark the two columns (including header row) and use the Subtotalbutton on the Data tab set like in this image:
Then the result would look something like this:
Price Category
240 19
231 19
233 19
231 19 Min
450 12
438 12
425 12
425 12 Min
674 33
675 33
671 33
671 33 Min
231 Grand Min
Try using this formula in C2 copied down
=IF(COUNTIFS(B:B,B2,A:A,"<"&A2),"",A2)
COUNTIFS here counts rows where the category matches and the price is lower than the current row. If there is no such row then the current row price must be lowest for that category and the price is returned.
If there are tied lowest prices within any category then they will all be shown

Resources