PowerPivot measure - Cacluate() using filter and "OR" syntax

zacc206

New Member
Joined
Jul 17, 2013
Messages
4
I am using the below measure in PowerPivot (Excel 2013):

Code:
=CALCULATE(COUNTA(ShoppingCart[Fruit]), ShoppingCart[Fruit]="Apple")

This will give me the the number of records in the "Fruit" column that are equal to "Apple". I'd like to include "Oranges" in my filter, so that I can have a count of records in the "Fruit" column that are either "Apple" or "Orange".

All the documentation I find on using filters in the CALCULATE() function describe how to do "Apple" and "Orange".

Does anyone know how to go about using "OR" syntax in the CALCULATE() function filter?
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
CALCULATE(COUNTA(ShoppingCart[Fruit]), ShoppingCart[Fruit]="Apple" || ShoppingCart[Fruit]="Orange")

Although my first inclination would be to use COUNTROWS instead of COUNTA. BTW, if you did want to do an AND, you can also use && and it would perform better than separating filters with a comma.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,212
Members
452,618
Latest member
Tam84

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