How do I create a measure to count the number of customers where the customer type is either FR or DE or GG.
In SQL, this would be something like
SELECT COUNT(customerId)
FROM dCustomers
WHERE customerType IN ('FR', 'DE', 'GG')
>Solution :
I would suggest using the IN operator, to write it in a more concise manner:
Count (Calculate) =
CALCULATE (
COUNTROWS ( dCustomers ) ,
dCustomers[customerType] IN {"FR", "DE", "GG"}
)
You can also use COUNTROWS directly on the filtered table, this looks to be marginally faster from a bit of testing on a random dataset, but please do benchmarking on a case by case basis:
Count (Filter) =
COUNTROWS (
FILTER (
dCustomers ,
dCustomers[customerType] IN {"FR", "DE", "GG"}
)
)