SUMIF - Based On Unique Values and Multiple Criteria

Creation

New Member
Joined
Apr 4, 2019
Messages
15
Good evening all,



I was wondering if someone would be kind enough to help mewith the following please?


What I am trying to achieve is the following:



  • Retrieve the gross balance for all accounts (excludingduplicates where there is >1 of the same entry / account) in Column A whilstalso using Status – ‘’Open’’ (Column C) & Concept – ‘’000’’ (Column D) as ‘Criteria’to drive the overall result returned in H2.


  • Retrieve the total number of accounts (excludingduplicates where there is >1 of the same entry / account) in Column A whilstalso using Concept – ‘’000’’ (Column D) as ‘Criteria’ to drive the overallresult returned in I2.


  • Retrieve the total number of accounts ‘’Off Sale’’in Column E (excluding duplicates where there is >1 of the same entry /account in Column A) whilst also using Status – ‘’Open’’ (Column C) &Concept – ‘’000’’ (Column D) as ‘Criteria’ to drive the overall result returnedin J2.


I have been a regular viewer of these forums for year but I haveseriously struggled with trying to achieve the above. I would be really gratefulif someone with more excel knowledge and expertise could help?

P.S - Example data and format below:

A B C D E G H I J
ACCOUNT
BALANCESTATUSCONCEPTON SALE / OFF SALEProductGross BalanceTotal # of A/CsA/Cs Off Sale
10293746£20.00OPEN000OFF SALEPRODUCT X
10394725£30.00OPEN000OFF SALEGrand Total£0.0000
10293645£33.00OPEN000OFF SALE
19273645£400.00OPEN000OFF SALE
10293029£1,000.00OPEN000OFF SALE
80974635£90.00OPEN000OFF SALE
10293029£43.00OPEN000OFF SALE
10293645£23.00OPEN000OFF SALE
10293645£1,900.00OPEN000OFF SALE
10293746£600.00OPEN000OFF SALE
10394725£320.00OPEN000OFF SALE
80974635£130.00OPEN000OFF SALE
80974635£500.00OPEN000OFF SALE
10293746£202.00OPEN000OFF SALE
10293746£909.00OPEN000OFF SALE
10394725£620.00OPEN000OFF SALE
10293029£340.00OPEN000OFF SALE
10293029£505.00OPEN000OFF SALE
10293029£9,000.00OPEN000OFF SALE
<colgroup><col width="68" style="width: 51pt; mso-width-source: userset; mso-width-alt: 2486;"> <col width="64" style="width: 48pt;" span="2"> <col width="65" style="width: 49pt; mso-width-source: userset; mso-width-alt: 2377;"> <col width="131" style="width: 98pt; mso-width-source: userset; mso-width-alt: 4790;"> <col width="18" style="width: 14pt; mso-width-source: userset; mso-width-alt: 658;"> <col width="82" style="width: 62pt; mso-width-source: userset; mso-width-alt: 2998;"> <col width="99" style="width: 74pt; mso-width-source: userset; mso-width-alt: 3620;" span="2"> <col width="90" style="width: 68pt; mso-width-source: userset; mso-width-alt: 3291;"> <tbody> </tbody>


Many Thanks in advance!!

 
Are you saying to count (or add) the rows whose STATUS column contains OPEN or PENDING?
Or should the rows contain the text OPEN & PENDING?

M.
 
Upvote 0

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Sorry should have clarified, i am saying to “add” the rows whose STATUS column contains OPEN & PENDING

Also, in relation to the first formula; if the CONCEPT column (000) is not formatted to text do you have any ideas how of I overcome the issue of the formula result returning nothing? I’ve been trying since this morning with no joy.

Ideally I need to the source data to stay in the format it it is. The reason for this is because the data extract I am working with has been imported from SQL into excel and converting the range or changing the format would result in the existing connections being lost, and the ability for the data to be refreshed would be lost. Also the format would revert back to its original upon the refresh of the data each morning.

Thank you once again!
 
Upvote 0
Check if column D (CONCEPT) contains number - try in an empty column
=ISNUMBER(D2)
and copy down

If the values are numbers try
=SUMPRODUCT(--(C2:C11="OPEN & PENDING"),--(D2:D11=0),--(MATCH(A2:A11,A2:A11,0)=ROW(A2:A11)-ROW(A2)+1),B2:B11)

M.
 
Upvote 0
Thanks for the suggestion! I fixed it by doing the following:

=SUMPRODUCT(--(C2:C11="OPEN")+(C2:C11="PENDING"),--(D2:D11="000"),--(MATCH(A2:A11,A2:A11,0)=ROW(A2:A11)-ROW(A2)+1),B2:B11)

The only thing I am still having trouble with is the CONCEPT ''000''. I did as you suggested and none of the values are numbers (the =ISNUMBER(D2) came back as false).

Any other ideas or suggestions matey?

Thanks!!
 
Upvote 0
Maybe...

=SUMPRODUCT(--((C2:C11="OPEN")+(C2:C11="PENDING")),--(TRIM(D2:D11)="000"),--(MATCH(A2:A11,A2:A11,0)=ROW(A2:A11)-ROW(A2)+1),B2:B11)

M.
 
Upvote 0
Thank for the above, I thought that would work but no joy.

I think I have narrowed it down to the match function of the formula: ,--(MATCH('Retail Products'!C2:C6753,'Retail Products'!C2:C6753,0)=ROW('Retail Products'!C2:C6753)-ROW('Retail Products'!C2)+1)

If I remove the above section from the formula and only keep: =SUMPRODUCT(--('Retail Products'!O2:O6753="OPEN"),--('Retail Products'!N2:N6753="000"),'Retail Products'!I2:I6753) the result I get is the full balance sum including duplicates based on STATUS = OPEN & CONCEPT = 000 (*At least we can rule out the formatting of the CONCEPT column is not the issue).

So in theory I am halfway there, I just need a way to report the full balance sum based on STATUS = OPEN, CONCEPT = 000 for unique accounts only. Is there anyway the formula can be amended?

Currently the full formula looks something like this: =SUMPRODUCT(--('Retail Products'!O2:O6753="OPEN"),--('Retail Products'!N2:N6753="000"),--(MATCH('Retail Products'!C2:C6753,'Retail Products'!C2:C6753,0)=ROW('Retail Products'!C2:C6753)-ROW('Retail Products'!C2)+1),'Retail Products'!I2:I6753)

The above is my live example from my actual document: O = STATUS, N = CONCEPT, C= ACCOUNT, I= BALANCE

Thank you once again for your support - I really appreciate it.

We will get there!! haha
 
Upvote 0
To find out the problem we need a new sample of data along with the expected results.

M.
 
Upvote 0

C

I

N

O

ACCOUNT

BALANCE

CONCEPT

STATUS

1

10009099

-£73.00

000

OPEN

2

10009099

-£73.00

PCA

OPEN

3

20890078

-£1789.34

000

OPEN

4

20890078

-£1789.34

343

OPEN

5

30457090

-£2010.10

000

OPEN

6

30457090

-£2010.10

PCI

OPEN

7

20011003

-£1500.90

000

OPEN

8

20011003

-£1500.90

968

OPEN

<tbody>
</tbody>





I need a way toreport the full balance sum based on STATUS = OPEN, CONCEPT = 000 for uniqueaccount entries only.

Expected result would be a total sum of -£5,373.34 (for those rows highlighted)

As it stands the data in the concept column is not stored as numbers (I checkedthis based on your advice using the =ISNUMBER formula).

In your original reply the MATCH function worked perfectly but it didnot work for me. When I removed the MATCH function it did work (as per myprevious reply) but summed all of the balances including theduplicate entries - I need it do unique entries only.

Hope this new data sample is better?

Thanks!!
 
Upvote 0
The formula I've suggested worked perfectly.


A
B
C
D
E
F
1
ACCOUNT​
BALANCE​
CONCEPT​
STATUS​
Result​
2
10009099​
-73,00​
000​
OPEN​
-5373,34​
3
10009099​
-73,00​
PCA​
OPEN​
4
20890078​
-1789,34​
000​
OPEN​
5
20890078​
-1789,34​
343​
OPEN​
6
30457090​
-2010,10​
000​
OPEN​
7
30457090​
-2010,10​
PCI​
OPEN​
8
20011003​
-1500,90​
000​
OPEN​
9
20011003​
-1500,90​
968​
OPEN​
10

Formula in F2
=SUMPRODUCT(--(C2:C9="000"),--(D2:D9="OPEN"),--(MATCH(A2:A9,A2:A9,0)=ROW(A2:A9)-ROW(A2)+1),B2:B9)

M.
 
Upvote 0
Yes correct. It works perfectly for the sample data but when I apply it to my source data set (which is very similar to the sample data) it does not work - I just get £0.00. Funny thing is if I remove the MATCH function from the formula then I get the total balance sum including duplicate accounts entries. Absolutely lost
 
Upvote 0

Forum statistics

Threads
1,215,086
Messages
6,123,033
Members
449,092
Latest member
ikke

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