Sum two lines based on being unique by the same Name

treeleaf20

Board Regular
Joined
Mar 17, 2009
Messages
159
Office Version
  1. 365
Platform
  1. Windows
I have the following entries in a spreadsheet:
[TABLE="class: grid, width: 600"]
<tbody>[TR]
[TD]Employee[/TD]
[TD]Date[/TD]
[TD]Days[/TD]
[TD]Total Balance[/TD]
[TD]Used Balance[/TD]
[TD]Booked Balance[/TD]
[TD]Remaining[/TD]
[/TR]
[TR]
[TD]Name1[/TD]
[TD][/TD]
[TD]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Name1[/TD]
[TD][/TD]
[TD]0[/TD]
[TD]2[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]Name1[/TD]
[TD]4/25/2019[/TD]
[TD]1[/TD]
[TD]20[/TD]
[TD]3[/TD]
[TD]0[/TD]
[TD]17[/TD]
[/TR]
[TR]
[TD]Name1[/TD]
[TD]4/26/2019[/TD]
[TD]1[/TD]
[TD]20[/TD]
[TD]3[/TD]
[TD]0[/TD]
[TD]17[/TD]
[/TR]
[TR]
[TD]Name2[/TD]
[TD][/TD]
[TD]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Name2[/TD]
[TD][/TD]
[TD]0[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Name2[/TD]
[TD]1/2/2019[/TD]
[TD]1[/TD]
[TD]37[/TD]
[TD]3[/TD]
[TD]32[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]Name2[/TD]
[TD]1/3/2019[/TD]
[TD]1[/TD]
[TD]37[/TD]
[TD]3[/TD]
[TD]32[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]Name2[/TD]
[TD]1/4/2019[/TD]
[TD]1[/TD]
[TD]37[/TD]
[TD]3[/TD]
[TD]32[/TD]
[TD]2[/TD]
[/TR]
</tbody>[/TABLE]

I would like the output to be something like this then:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Employee[/TD]
[TD]Total Balance[/TD]
[TD]Used Balance[/TD]
[TD]Booked Balance[/TD]
[TD]Remaining Balance[/TD]
[/TR]
[TR]
[TD]Name1[/TD]
[TD]22[/TD]
[TD]3[/TD]
[TD]0[/TD]
[TD]19[/TD]
[/TR]
[TR]
[TD]Name2[/TD]
[TD]37[/TD]
[TD]3[/TD]
[TD]32[/TD]
[TD]2[/TD]
[/TR]
</tbody>[/TABLE]

Basically, I'd like to only select a unique row where the total balance, used balance, booked balance, and remaining balance aren't the same and then sum those selections together.

In the Name1, you can see the two rows that aren't unique so when I sum them I get the output. For Name2, all the rows are unique so I would only like to select the one row.

Any ideas on how to do this with a formula?
 
Last edited:

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
I found this thread which I got to work but I have no idea what the formula is doing to learn from it. If anyone could provide some guidance that would be ideal on what the formula is calcuating:

https://www.mrexcel.com/forum/excel-questions/988783-sum-unique-values-based-criteria.html

=IF($A5="","",SUM(IF(FREQUENCY(IF('Time Off Report'!$D$2:$D$5000=$A5,MATCH('Time Off Report'!G$2:G$5000,'Time Off Report'!G$2:G$5000,0)),ROW('Time Off Report'!G$2:G$5000)-ROW('Time Off Report'!G$2)+1),'Time Off Report'!G$2:G$5000)))
 
Upvote 0
Try this

<table border="1" cellspacing="0" style="font-family:Calibri,Arial; font-size:11pt; background-color:#ffffff; "> <colgroup><col style="font-weight:bold; width:30px; " /><col style="width:65.58px;" /><col style="width:78.89px;" /><col style="width:37.07px;" /><col style="width:92.2px;" /><col style="width:90.3px;" /><col style="width:55.13px;" /><col style="width:68.44px;" /><col style="width:19.96px;" /><col style="width:65.58px;" /><col style="width:84.59px;" /><col style="width:84.59px;" /><col style="width:99.8px;" /><col style="width:118.81px;" /></colgroup><tr style="background-color:#cacaca; text-align:center; font-weight:bold; font-size:8pt; "><td > </td><td >A</td><td >B</td><td >C</td><td >D</td><td >E</td><td >F</td><td >G</td><td >H</td><td >I</td><td >J</td><td >K</td><td >L</td><td >M</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >1</td><td style="background-color:#ffff00; font-weight:bold; text-align:center; ">Employee</td><td style="background-color:#ffff00; font-weight:bold; text-align:center; ">Date</td><td style="background-color:#ffff00; font-weight:bold; text-align:center; ">Days</td><td style="background-color:#ffff00; font-weight:bold; text-align:center; ">Total Balance</td><td style="background-color:#ffff00; font-weight:bold; text-align:center; ">Used Balance</td><td style="background-color:#ffff00; font-weight:bold; text-align:center; ">Booked Balance</td><td style="background-color:#ffff00; font-weight:bold; text-align:center; ">Remaining</td><td style="background-color:#ffff00; font-weight:bold; "> </td><td style="background-color:#ffff00; font-weight:bold; text-align:center; ">Employee</td><td style="background-color:#ffff00; font-weight:bold; text-align:center; ">Total Balance</td><td style="background-color:#ffff00; font-weight:bold; text-align:center; ">Used Balance</td><td style="background-color:#ffff00; font-weight:bold; text-align:center; ">Booked Balance</td><td style="background-color:#ffff00; font-weight:bold; text-align:center; ">Remaining Balance</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >2</td><td >Name1</td><td > </td><td style="text-align:right; ">0</td><td > </td><td > </td><td > </td><td > </td><td > </td><td >Name1</td><td style="text-align:right; ">22</td><td style="text-align:right; ">3</td><td style="text-align:right; ">0</td><td style="text-align:right; ">19</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >3</td><td >Name1</td><td > </td><td style="text-align:right; ">0</td><td style="text-align:right; ">2</td><td style="text-align:right; ">0</td><td style="text-align:right; ">0</td><td style="text-align:right; ">2</td><td > </td><td >Name2</td><td style="text-align:right; ">37</td><td style="text-align:right; ">3</td><td style="text-align:right; ">32</td><td style="text-align:right; ">2</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >4</td><td >Name1</td><td style="text-align:right; ">4/25/2019</td><td style="text-align:right; ">1</td><td style="text-align:right; ">20</td><td style="text-align:right; ">3</td><td style="text-align:right; ">0</td><td style="text-align:right; ">17</td><td > </td><td > </td><td > </td><td > </td><td > </td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >5</td><td >Name1</td><td style="text-align:right; ">4/26/2019</td><td style="text-align:right; ">1</td><td style="text-align:right; ">20</td><td style="text-align:right; ">3</td><td style="text-align:right; ">0</td><td style="text-align:right; ">17</td><td > </td><td > </td><td > </td><td > </td><td > </td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >6</td><td >Name2</td><td > </td><td style="text-align:right; ">0</td><td > </td><td > </td><td > </td><td > </td><td > </td><td > </td><td > </td><td > </td><td > </td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >7</td><td >Name2</td><td > </td><td style="text-align:right; ">0</td><td > </td><td > </td><td > </td><td > </td><td > </td><td > </td><td > </td><td > </td><td > </td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >8</td><td >Name2</td><td style="text-align:right; ">43497</td><td style="text-align:right; ">1</td><td style="text-align:right; ">37</td><td style="text-align:right; ">3</td><td style="text-align:right; ">32</td><td style="text-align:right; ">2</td><td > </td><td > </td><td > </td><td > </td><td > </td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >9</td><td >Name2</td><td style="text-align:right; ">43525</td><td style="text-align:right; ">1</td><td style="text-align:right; ">37</td><td style="text-align:right; ">3</td><td style="text-align:right; ">32</td><td style="text-align:right; ">2</td><td > </td><td > </td><td > </td><td > </td><td > </td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >10</td><td >Name2</td><td style="text-align:right; ">43556</td><td style="text-align:right; ">1</td><td style="text-align:right; ">37</td><td style="text-align:right; ">3</td><td style="text-align:right; ">32</td><td style="text-align:right; ">2</td><td > </td><td > </td><td > </td><td > </td><td > </td><td > </td></tr></table><br /><table style="font-family:Arial; font-size:10pt; border-style: groove ;border-color:#00ff00;background-color:#fffcf9; color:#000000; "><tr><td ><b></b></td></tr><tr><td ><table border = "1" cellspacing="0" cellpadding="2" style="font-family:Arial; font-size:9pt;"><tr style="background-color:#cacaca; font-size:10pt;"><td >Cell</td><td >Array Formula</td></tr><tr><td >J2</td><td >{=SUMPRODUCT(IFERROR(($A$2:$A$10=$I2)*(MATCH($A$2:$A$10&$C$2:$C$10,IF($D$2:$D$10>0,$A$2:$A$10&$C$2:$C$10),0)=ROW($C$2:$C$10)-1),0)*(D$2:D$10))}</td></tr></table></td></tr></table>


Array formulas
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

Copy down and copy right
 
Upvote 0

Forum statistics

Threads
1,223,898
Messages
6,175,272
Members
452,628
Latest member
dd2

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