Sum column based on unique values in another column

samide2001

New Member
Joined
Feb 2, 2024
Messages
11
Office Version
  1. 365
Platform
  1. MacOS
All of the formulas I am doing will be on a summary tab that looks at data added on another tab "Jan". So I cannot add helper columns. The number of rows per column will change each month, and the number of duplicates will also change. So, if the formula could be derived to look at the entire column that would be great!

On the summary tab, I need the formula to look at the data in column W and sum the values for the unique numbers in column A. I also need the formula to subtract out the values from column W if column B has "canceled" as the status (also removing any duplicates). So, for the example below the correct value returned should be $7.65 for column W based on the uniqe values of column A - canceled orders in Column B.

2024 - TikTokShop Sales and Fees - Quick Numbers.xlsx
ABCW
1Order IDOrder StatusOrder SubstatusTaxes
2Platform unique order ID.Current order status.
3576577737861468321ShippedIn Transit1.09
4576575207724716077ShippedIn Transit5.26
5576575207724716077ShippedIn Transit5.26
6576575207724716077ShippedIn Transit5.26
7576575207724716077ShippedIn Transit5.26
8576573793136054581ShippedDelivered0.7
9576568733552841200ShippedDelivered0.6
10576568733126005232CanceledCanceled0.6
Jan


Here is the summary tab: The formula I need will go in cell B6

2024 - TikTokShop Sales and Fees - Quick Numbers.xlsx
ABC
3Revenue
4Sales$ 93.00$ -
5Shipping$ 9.31$ -
6Sales Tax$ 7.65$ -
7Canceled Orders$ 10.00$ -
8Shop Revenue$ 84.66$ -
9
10Expenses
11Selling Expenses
12Referral Fees$ 4.19$ -
13Affiliate Commisions$ 3.00$ -
14Shipping Fee$ 16.98$ -
15Total Expenses$ 24.17$ -
16
17Net Profit$ 60.49$ -
Monthly Summary
Cell Formulas
RangeFormula
B4B4=SUM(Jan!$M:$M)
B5B5=SUMIF(Jan!$B:$B, "<>"&"Canceled", Jan!$Q:$Q)
C4C4=SUM(Feb!$M:$M)
C5C5=SUMIF(Feb!$B:$B, "<>"&"Canceled", Feb!$Q:$Q)
C6C6=SUM(Feb!$W:$W)
B7B7=SUMIF(Jan!$B:$B, "Canceled", Jan!$Y:$Y)-SUMIF(Jan!$B:$B, "Canceled", Jan!$W:$W)
C7C7=SUMIF(Feb!$B:$B, "Canceled", Feb!$Y:$Y)-SUMIF(Feb!$B:$B, "Canceled", Feb!$W:$W)
B8B8=SUM(B4+B5-B6-B7)
C8C8=SUM(C4+C5-C6-C5)
B12B12=-SUM('Jan2'!$Y:$Y)
C12C12=-SUM('Feb2'!$Y:$Y)
B13B13=-SUM('Jan2'!$AD:$AD)
C13C13=-SUM('Feb2'!$AD:$AD)
B14B14=-SUM('Jan2'!$Z:$Z)
C14C14=-SUM('Feb2'!$Z:$Z)
B15:C15B15=SUM(B12:B14)
B17:C17B17=B8-B15



I have tried a sumif formula with unique as the criteria, but got a spill error. When I moved it out this is the data I got (this was the first part before trying to figure out how to subtract column B):
2024 - TikTokShop Sales and Fees - Quick Numbers.xlsx
D
271.09
28$ 21.04
29$ 0.70
30$ 0.60
31$ 0.60
32$ -
Monthly Summary
Cell Formulas
RangeFormula
D27:D32D27=SUMIF(Jan!A:A,UNIQUE(Jan!$A3:A99999,FALSE,FALSE),Jan!W:W)
Dynamic array formulas.
 
Glad we could help & thanks for the feedback.
 
Upvote 0

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Glad we could help & thanks for the feedback.
Thanks so much for the help! If you could help with this query I would greatly appreciate it!
I tried to replicate what your answer was from here, but was unable to apply the same principles to the new issue.
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,179
Members
452,615
Latest member
bogeys2birdies

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