Using Adventureworks DW 2008 cube I'm trying to build an MDX query that will return a count of internet orders that did not have a specific reason code for the order.
FactInternetSales has a Many to many with FactInternetSalesReason. Each sale has 1 or more reason codes.
If I try to return orders that didn't use the "On Promotion" reason, I still get the on promotion orders included in the count because they also have other reasons on them.
How do I write the MDX to say that if this order has this reason, don't include it in the count, without regard to any other reasons?
The equivalent SQL against the adventure works sql data warehouse would be:
select count(distinct salesordernumber) from FactInternetSales
where not exists (select salesorderNumber
from FactInternetSalesReason
where SalesReasonKey = 2
and FactInternetSales.SalesOrderNumber = FactInternetSalesReason.SalesOrderNumber
)