count invoices with multiple AND filters

MrAnderson

New Member
Joined
Mar 6, 2014
Messages
6
Hi,

I’m trying to count the number of instances where a customer has bought 2 particular products in the same invoice. Let’s assume I have the following table called "invoices.


ABCDE
1InvoiceIdInvoiceDateProductIDPriceProductName
2101/01/20121100a
3101/01/2012250b
4202/02/20121100a
5202/02/2012425d
6303/03/20121100a
7303/03/2012250b
8303/03/2012525e

<colgroup><col style="width: 25pxpx"><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Facturas



The result I want is the following

HI
2Jan1
3Feb0
4March1

<colgroup><col style="width: 25pxpx"><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Facturas



I have tried with the CALCULATE function with these formulae:
=calculate(distinctcount(Invoices[InvoiceId],Invoices[ProdId]=1;Invoices[ProdId]=2)
Or
=calculate(distinctcount(Invoices[InvoiceId],Invoices[ProdId]=1&&Invoices[ProdId]=2)

but I get no results, can anyone give a hand?

thanks a lot!.
 
CALCULATE can take any number of filter params. You currently have one which is "which invoices do we even consider?". Now you want to add another which is "Only include Products 1 or 2".

That reads okay, and maybe it is correct!?

FILTER(ALL(Invoices[ProductId]), Invoices[ProductId] = 1 || Invoices[ProductId] = 2)

(This would be your 3rd param to the outer calculate)
 
Upvote 0

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Sweet, that's how you can do it. Didn't think of that. I was thinking putting the logic into one filter expression
 
Upvote 0

Forum statistics

Threads
1,215,465
Messages
6,124,973
Members
449,200
Latest member
Jamil ahmed

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