日期:2014-05-18  浏览次数:20583 次

好奇怪???
总见有人问MDX语句,可为什么我做的BI项目从来没有用过MDX呢?有没有人能跟我说说MDX到底怎么回事呀!或许做项目能有更好的方法,呵呵,希望各抒己见,盼复!!

------解决方案--------------------

SQL code


查出最近6个月销售趋势最好的前10个商品及其各自销售量
 
withset [TenBest] as 'TopCount( [Product].[Brand Name].Members, 10, [Unit Sales] )'
 set [LastMonth] as 'Tail(Filter([Time].[Month].Members, NotIsEmpty([Time].CurrentMember)),1)'
 set [Last6Months] as ' [LastMonth].item(0).item(0).Lag(6) : [LastMonth].item(0).item(0)'
select [Last6Months] onCOLUMNS,
 [TenBest] onROWS
from Sales

找出组成销售额80%的商品销售及其记录;
select {[Unit Sales]} onCOLUMNS,
TopPercent([Product].[Brand Name].Members, 80, [Unit Sales]) onROWS
from Sales


按销售量排序,找出组成20%销售量的商品销售记录
select {[Unit Sales]} onCOLUMNS,
 NonEmptyBottomPercent([Product].[Brand Name].Members, 20, [Unit Sales]) onROWS
from Sales


查出销售量最好的前5名店和每个店的前5个顾客及其销售记录
 select {[Unit Sales]} onCOLUMNS,
 Generate( TopCount([Store].[Store Name].Members, 5, [Unit Sales]),
 { [Store].CurrentMember } * TopCount( [Customers].[Name].Members, 5, ([Unit Sales], 
[Store].CurrentMember) ) ) onROWS
from Sales