下面的內(nèi)容經(jīng)過完整的測試,結(jié)合了網(wǎng)上看到的其他文章,修改整理。
創(chuàng)新互聯(lián)是專業(yè)的環(huán)翠網(wǎng)站建設(shè)公司,環(huán)翠接單;提供成都做網(wǎng)站、成都網(wǎng)站建設(shè),網(wǎng)頁設(shè)計,網(wǎng)站設(shè)計,建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行環(huán)翠網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴(kuò)展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團(tuán)隊,希望更多企業(yè)前來合作!
測試環(huán)境如下:
windows 2003 sp2
mondrian-3.1.1.12687
jdk1.6
tomcat 5.5.23
LISTING 1: Determining Products Sold in Each State
說明:每個州(省)都在銷售的產(chǎn)品
[en]
with set [SoldInUSA] as 'Filter([Product].[Brand Name].Members, Not IsEmpty( ([USA], [Unit Sales]) ))'
member [Measures].[SoldInState] as 'iif( IsEmpty(([Product].CurrentMember, [Unit Sales], [Customers].CurrentMember)), "No","Yes" )'
select [USA].children on COLUMNS,
[SoldInUSA] on ROWS
from Sales
where ([Measures].[SoldInState])
[cn]
with set [SoldInUSA] as 'Filter([Product].[Brand Name].Members, Not IsEmpty( ([美國], [Unit Sales]) ))'
member [Measures].[SoldInState] as 'iif( IsEmpty(([Product].CurrentMember, [Unit Sales], [Customers].CurrentMember)), "No","Yes" )'
select [美國].children on COLUMNS,
[SoldInUSA] on ROWS
from Sales
where ([Measures].[SoldInState])
LISTING 2: Determining Top 10 Product Categories
說明:列出銷售額排名前十的產(chǎn)品類別
select {[Measures].[Unit Sales]} ON COLUMNS,
TopCount([Product].[Product Category].Members, 10.0, [Measures].[Unit Sales]) ON ROWS
from [Sales]
Listing_03.Determining Brands Sold During the Past Three Quarters.txt
說明:列出過去三個季度里都存在銷售量的商品銷售記錄
[en]
with set [LastQuarter] as 'Tail(Filter([Time].[Quarter].Members, Not IsEmpty([Time].CurrentMember)),1)'
set [Last3Quarters] as ' [LastQuarter].item(0).item(0).Lag(2) : [LastQuarter].item(0).item(0)'
select [Last3Quarters] on COLUMNS,
Non Empty Union(Descendants( [Food], [Product].[Brand Name] ), Descendants( [Drink], [Product].[Brand Name] )) on ROWS
from Sales
[cn]
with set [LastQuarter] as 'Tail(Filter([Time].[Quarter].Members, Not IsEmpty([Time].CurrentMember)),1)'
set [Last3Quarters] as ' [LastQuarter].item(0).item(0).Lag(2) : [LastQuarter].item(0).item(0)'
select [Last3Quarters] on COLUMNS,
Non Empty Union(Descendants( [食品], [Product].[Brand Name] ), Descendants( [飲用類], [Product].[Brand Name] )) on ROWS
from Sales
Listing_04.Determining Recent Trends for Best-Selling Brands.txt
說明:查出最近6個月銷售趨勢最好的前10個商品及銷售量
with set [TenBest] as 'TopCount( [Product].[Brand Name].Members, 10, [Unit Sales] )'
set [LastMonth] as 'Tail(Filter([Time].[Month].Members, Not IsEmpty([Time].CurrentMember)),1)'
set [Last6Months] as ' [LastMonth].item(0).item(0).Lag(6) : [LastMonth].item(0).item(0)'
select [Last6Months] on COLUMNS,
[TenBest] on ROWS
from Sales
Listing_05.Determining Brands that Make Up 80 Percent of Sales.txt
說明:找出組成銷售額80%的商品銷售及其記錄
select {[Unit Sales]} on COLUMNS,
TopPercent([Product].[Brand Name].Members, 80, [Unit Sales]) on ROWS
from Sales
Listing_06.Determining Brands That Make Up the Bottom 20 Percent of Sales.txt
說明:按銷售量排序,找出組成20%銷售量的商品銷售記錄
select {[Unit Sales]} on COLUMNS,
Non Empty BottomPercent([Product].[Brand Name].Members, 20, [Unit Sales]) on ROWS
from Sales
Listing_07.Determining the Top Five Stores and the Top Five Customers.txt
說明:查出銷售量最好的前5名店和每個店的前5個顧客 及其銷售記錄
select {[Unit Sales]} on COLUMNS,
Generate( TopCount([Store].[Store Name].Members, 5, [Unit Sales]),
{ [Store].CurrentMember } * TopCount( [Customers].[Name].Members, 5, ([Unit Sales],
[Store].CurrentMember) ) ) on ROWS
from Sales
Listing_08.Determining Two Top-Selling Products.txt
說明:查出每種產(chǎn)品大類 前2名 產(chǎn)品小類型號的銷售記錄,以及小類型號占大類的百分比
with member [Measures].[PercTotalSales] as
' Sum( TopCount([Product].CurrentMember.Children, 2, [Unit Sales]), [Unit Sales] )
/([Product].CurrentMember, [Unit Sales])',
FORMAT_STRING = '##.0%'
select [Store].[(All)].Members on COLUMNS,
Generate( [Product].[Brand Name].Members,
Union(
TopCount( [Product].CurrentMember.Children, 2, [Unit Sales] ) * {[Unit Sales]},
{ ([Product].CurrentMember, [Measures].[PercTotalSales]) }
)
) on ROWS
from Sales
===============================
Listing_09.Highlighting Products in the Bottom 10 Percent.txt
說明:查出4個季度中,每個時期銷售量在后10%的產(chǎn)品銷售量,并顯示為粗體
with set [LastQuarter] as 'Tail(Filter([Time].[Quarter].Members, Not
IsEmpty([Time].CurrentMember)))'
set [Last4Quarters] as ' [LastQuarter].item(0).item(0).Lag(3) : [LastQuarter].item(0).item(0)'
member [Measures].[HLUnit Sales] as '[Unit Sales]',
FONT_FLAGS = 'iif( Count(
Intersect( BottomPercent( [Product].[Brand Name].Members, 10, ([Unit Sales]) ),
{[Product].CurrentMember})
) = 0, 0, 1)'
select [Last4Quarters] on COLUMNS,
[Product].[Brand Name].Members on ROWS
from Sales
where ([Measures].[HLUnit Sales])
cell properties VALUE, FORMATTED_VALUE, FONT_FLAGS
Listing_10.Comparing Sales with Those of Parallel Months.txt
說明:比較具有相同相對位置的時間點(diǎn)的銷售量,例如今年7月和去年7月;
with set [PromoMonths] as 'Filter([Time].[Month].Members, Not IsEmpty( ([Unit Sales], [Double Your Savings]) ) )'
set [PromoRange] as 'Head( [PromoMonths] ).item(0).item(0) : Tail( [PromoMonths] ).item(0).item(0)'
member [Measures].[Uplift] as '([Unit Sales], [Double Your Savings])'
member [Measures].[This Quarter] as '[Unit Sales]'
member [Measures].[Last Quarter] as '( ParallelPeriod( [Time].[Quarter] ), [Unit Sales] )'
member [Measures].[Growth] as ' [Measures].[This Quarter] - [Measures].[Last Quarter]'
select [PromoRange] on Columns,
{ [Measures].[This Quarter], [Measures].[Last Quarter], [Measures].[Growth], [Measures].[Uplift] } on Rows
from [Sales]
Listing_11.Determining Sales That Exceed Store Cost by 160 Percent.txt
說明:查出利潤率在16%以上的產(chǎn)品及銷售記錄
with member [Measures].[SalesRatio] as '([Store Sales] - [Store Cost]) / [Store Cost]',
FORMAT_STRING = '##%'
select { [Store Sales], [Store Cost], [Measures].[SalesRatio] } on COLUMNS,
Filter( [Product].[Brand Name].Members, [Measures].[SalesRatio] > 1.60 ) on ROWS
from Sales
Listing_12.Determining Brands that Have Grown by More Than 50 Percent.txt
說明:找出最近一季度比前一季度銷售量增長幅度大于50%的產(chǎn)品銷售記錄
with set [LastQuarter] as 'Tail(Filter([Time].[Quarter].Members, Not
IsEmpty([Time].CurrentMember)))'
member [Measures].[CurrQSales] as '([LastQuarter].item(0).item(0), [Unit Sales])'
member [Measures].[PrevQSales] as '([LastQuarter].item(0).item(0).PrevMember, [Unit Sales])'
member [Measures].[Growth] as ' ([Measures].[CurrQSales] - [Measures].[PrevQSales]) / [Measures].[PrevQSales]',
FORMAT_STRING='##%'
select { [Measures].[PrevQSales], [Measures].[CurrQSales], [Measures].[Growth] } on COLUMNS,
Filter( [Product].[Brand Name].Members, [Measures].[Growth] > 0.5 ) on ROWS
from Sales
Listing_13.Determing the Top 10 and Bottom 10 Product Brands.txt
說明:找出銷售額在前、后10名的產(chǎn)品銷售記錄,并列出總排名,就是找出銷售情況最好和最壞的產(chǎn)品
with set [OrderedBrands] as 'Order( [Product].[Brand Name].Members, [Unit Sales], BDESC )'
member [Measures].[Brand Rank] as 'Rank( [Product].CurrentMember, [OrderedBrands] )'
select {[Measures].[Brand Rank], [Unit Sales]} on COLUMNS,
Union( Head( [OrderedBrands], 10 ), Tail( [OrderedBrands], 10 ) ) on ROWS
from Sales
Listing_14.Comparing Product Trends.txt
說明:比較一下產(chǎn)品銷售趨勢,沒什么用
with set [LastQuarter] as 'Tail(Filter([Time].[Quarter].Members, Not
IsEmpty([Time].CurrentMember)))'
set [Last4Quarters] as ' [LastQuarter].item(0).item(0).Lag(3) : [LastQuarter].item(0).item(0)'
member [Measures].[GroupAvg] as 'Avg([Product].CurrentMember.Siblings, [Unit Sales])'
member [Measures].[AllAvg] as 'Avg( [Product].[Product Name].Members, [Unit Sales])'
select [Last4Quarters] on COLUMNS,
{ [Unit Sales], [Measures].[GroupAvg], [Measures].[AllAvg] } on ROWS
from Sales
/*where ([Ebony Plums])*/
Listing_15.Determining the Top 10 Middle-Tier Brands.txt
說明:查出一定條件下的前10名產(chǎn)品的銷售記錄,例如銷售量在500到3000之間的
with set [LastQuarter] as 'Tail(Filter([Time].[Quarter].Members, Not
IsEmpty([Time].CurrentMember)))'
set [Last4Quarters] as ' [LastQuarter].item(0).item(0).Lag(3) : [LastQuarter].item(0).item(0)'
member [Measures].[GroupAvg] as 'Avg([Product].CurrentMember.Siblings, [Unit Sales])'
member [Measures].[AllAvg] as 'Avg( [Product].[Product Name].Members, [Unit Sales])'
member [measures].[abc] as '[Product].CurrentMember.uniquename'
select [Last4Quarters] on COLUMNS,
{ [Unit Sales], [measures].[GroupAvg], [measures].[AllAvg],[measures].[abc] } on ROWS
from Sales
/*where ([Ebony Plums])*/
本文名稱:FoodMart的15個mdx例子,絕對一一經(jīng)過測試,保證正確
標(biāo)題URL:http://jinyejixie.com/article28/iisecp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供搜索引擎優(yōu)化、全網(wǎng)營銷推廣、服務(wù)器托管、企業(yè)網(wǎng)站制作、動態(tài)網(wǎng)站、建站公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)