I have a table, simplified as follows - FactSales:
Date Reference Amount TypeId Seller
1/10/2013 A1 100 1 100
3/10/2013 A2 200 1 200
5/10/2013 A1 -100 2 100
And foreign key tables for DimType - 1 as sale, 2 as refund, and DimSellers. Also have a DimDate table etc.
Essentially, this is all processed into a SSAS cube, and am now attempting to create MDX queries to count the total the number of sales, not the sum of the sales amounts. Colums should represent Seller and rows the months for the previous 12 months to current. I am successfully able to perform a count with the seller in the columns and months as rows, but only filtering on the type 1 for sales.
The part i am a little caught on is that a sale should only count as a sale in the month, if the sale was not refunded (type 2) in the same month. If it was refunded in a future month after the type 1 sale, it should be counted. If refunded in the same month as sold, it should not count as a sale.
Expected results should be from my example. As A1 was refunded in the same month as it was sold it's not counted as a sale in October.
Seller 100. Seller 200. ...
Oct 13. 0. 1
Sept 13 ...
Aug 13 ...
...
Nov 12 ...
Any help is appreciated.
Oct13 | Seller100: 0 | Seller200: 200
. Don't know where these0
and1
in your expectation are comming from. – DHN