Formula to populate cell based on multiple column/row results

KayJay0618

New Member
Joined
Jul 20, 2016
Messages
40
I don't have a clue how to search for something to help me with this problem. I have a worksheet with 5 columns (num, FY-Qtr, OP, UP, Qtr Result). I need to populate the Qtr Result column with the word Keep IF the total of the OP and UP columns for an FY-Qtr and Num is greater than zero. If there is nothing but 0 in the OP and UP columns for a Num and FY-Qtr I need to populate the Qtr Result column with Delete. I've attached a sample. You can see that for num 4071151, there are numbers greater than zero on all 5 rows for FY15-Q3 so I would want to populate column E with Keep on all 5 of those rows. I would also want Keep in column E for all 6 rows for FY15-Q4 because 2 of the rows have numbers greater than 0 in the OP or UP column. But column E for all of the FY16-Q1 rows for num 4071151 should be populated with the word Delete because none of the OP/UP columns for FY16-Q1 have numbers greater than 0. I have several thousand records I need to resolve QUICKLY and I just can't seem to figure this one out. I'm thinking it's some sort of sumproduct formula but I'm really struggling with figuring it out and maybe I'm off track. Thank you in advance! :confused:


Num

FY-QTR

OP

UP

Qtr Result

4071151

FY15-Q3

0

35.68

Keep

4071151

FY15-Q3

0

66.45

Keep

4071151

FY15-Q3

0

31.17

Keep

4071151

FY15-Q3

0

31.17

Keep

4071151

FY15-Q3

0

31.17

Keep

4071151

FY15-Q4

0

31.17

Keep

4071151

FY15-Q4

0

31.17

Keep

4071151

FY15-Q4

0

0

Keep

4071151

FY15-Q4

0

0

Keep

4071151

FY15-Q4

0

0

Keep

4071151

FY15-Q4

0

0

Keep

4071151

FY16-Q1

0

0

Delete

4071151

FY16-Q1

0

0

Delete

4071151

FY16-Q1

0

0

Delete

4071151

FY16-Q2

0

0

Delete

4071151

FY16-Q2

0

0

Delete

4071151

FY16-Q2

0

0

Delete

4066704

FY14-Q3

0

63.83

Keep

4066704

FY14-Q3

20.19

0

Keep

4066704

FY14-Q3

0

0

Keep

4066704

FY14-Q3

25.7

0

Keep

4065758

FY14-Q2

0

0

Delete

4065758

FY14-Q2

0

0

Delete

4065758

FY14-Q2

0

0

Delete

4065758

FY14-Q3

0.21

0

Keep

4065758

FY14-Q3

0

0

Keep

4065758

FY14-Q3

0

0

Keep

4065758

FY14-Q4

0

0

Delete

4065758

FY14-Q4

0

0

Delete

<tbody>
</tbody>
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Assuming data starts in A1, in E2:

=IF(SUMIF(B:B,B2,C:C)+SUMIF(B:B,B2,D:D)>0,"Keep","Delete")
 
Upvote 0
Unfortunately this does not work. Column A is the customer number, Column B is the FY-Qtr. If column C (OP) is > 0 there is an overpayment and if column D (UP) is > 0 there is an overpayment. For every customer number there is a potential for multiple rows representing up to 10 FY-Qtrs each of which could have multiple rows. In my sample customer 4071151 has 4 FY-Qtrs. FY15-Q3 has 5 rows, all of which have an underpayment (UP) so I would need to KEEP all 5 of those rows. FY15-Q4 has 6 rows, two of which have amounts >0 in the UP column, so I would need to keep ALL 6 rows for FY15-Q4. FY-16-Q1 has 3 rows, none of which have an OP or UP so I need to DELETE all 3 of those rows. Perhaps this will better explain what I'm trying to do:

For those rows where the values in columns A and B are the same AND the sum of the values in column C is >0 OR the sum of the values in column D is >0 then Keep
For those rows where the values in columns A and B are the same AND the sum of the values in columns C =0 AND the sum of the values in column D =0 then Delete
 
Last edited:
Upvote 0
Maybe something like this

E2 copied down
=IF(SUMPRODUCT(--(A$2:A$1000=A2),--(B$2:B$1000=B2),C$2:C$1000+D$2:D$1000),"Keep","Delete")

M.
 
Upvote 0
That didn't work. However, between your two answers I was able to get over my blocked state and figured out a way to do it. Thank you!
 
Upvote 0
That didn't work. However, between your two answers I was able to get over my blocked state and figured out a way to do it. Thank you!

It works, for sure!

Just for the records


A
B
C
D
E
1
Num​
FY-QTR​
OP​
UP​
Qtr Result​
2
4071151​
FY15-Q3​
0​
35,68​
Keep​
3
4071151​
FY15-Q3​
0​
66,45​
Keep​
4
4071151​
FY15-Q3​
0​
31,17​
Keep​
5
4071151​
FY15-Q3​
0​
31,17​
Keep​
6
4071151​
FY15-Q3​
0​
31,17​
Keep​
7
4071151​
FY15-Q4​
0​
31,17​
Keep​
8
4071151​
FY15-Q4​
0​
31,17​
Keep​
9
4071151​
FY15-Q4​
0​
0​
Keep​
10
4071151​
FY15-Q4​
0​
0​
Keep​
11
4071151​
FY15-Q4​
0​
0​
Keep​
12
4071151​
FY15-Q4​
0​
0​
Keep​
13
4071151​
FY16-Q1​
0​
0​
Delete​
14
4071151​
FY16-Q1​
0​
0​
Delete​
15
4071151​
FY16-Q1​
0​
0​
Delete​
16
4071151​
FY16-Q2​
0​
0​
Delete​
17
4071151​
FY16-Q2​
0​
0​
Delete​
18
4071151​
FY16-Q2​
0​
0​
Delete​
19
4066704​
FY14-Q3​
0​
63,83​
Keep​
20
4066704​
FY14-Q3​
20,19​
0​
Keep​
21
4066704​
FY14-Q3​
0​
0​
Keep​
22
4066704​
FY14-Q3​
25,7​
0​
Keep​
23
4065758​
FY14-Q2​
0​
0​
Delete​
24
4065758​
FY14-Q2​
0​
0​
Delete​
25
4065758​
FY14-Q2​
0​
0​
Delete​
26
4065758​
FY14-Q3​
0,21​
0​
Keep​
27
4065758​
FY14-Q3​
0​
0​
Keep​
28
4065758​
FY14-Q3​
0​
0​
Keep​
29
4065758​
FY14-Q4​
0​
0​
Delete​
30
4065758​
FY14-Q4​
0​
0​
Delete​

<tbody>
</tbody>


Formula in E2 copied down (same formula as post 4)
=IF(SUMPRODUCT(--(A$2:A$1000=A2),--(B$2:B$1000=B2),C$2:C$1000+D$2:D$1000),"Keep","Delete")

M.
 
Last edited:
Upvote 0
If the formula produced a #VALUE error i suspect there is (are) some cell(s) in the C or D columns that contains a text, not a number.

M.
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,243
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top