千家信息网

FoodMart的15个mdx例子,绝对一一经过测试,保证正确

发表于:2025-01-23 作者:千家信息网编辑
千家信息网最后更新 2025年01月23日,下面的内容经过完整的测试,结合了网上看到的其他文章,修改整理。测试环境如下:windows 2003 sp2mondrian-3.1.1.12687jdk1.6tomcat 5.5.23LISTING
千家信息网最后更新 2025年01月23日FoodMart的15个mdx例子,绝对一一经过测试,保证正确

下面的内容经过完整的测试,结合了网上看到的其他文章,修改整理。

测试环境如下:

windows 2003 sp2

mondrian-3.1.1.12687

jdk1.6

tomcat 5.5.23

LISTING 1: Determining Products Sold in Each State
说明:每个州(省)都在销售的产品
[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
说明:列出销售额排名前十的产品类别
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
说明:查出每种产品大类 前2名 产品小类型号的销售记录,以及小类型号占大类的百分比
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%的产品销售量,并显示为粗体
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
说明:比较具有相同相对位置的时间点的销售量,例如今年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%以上的产品及销售记录
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%的产品销售记录
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名的产品销售记录,并列出总排名,就是找出销售情况最好和最坏的产品
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
说明:比较一下产品销售趋势,没什么用
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名产品的销售记录,例如销售量在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])*/

销售 产品 销售量 商品 产品销售 最好 销售额 测试 大类 季度 类型 趋势 美国 相同 没什么 三个 之间 位置 内容 利润 数据库的安全要保护哪些东西 数据库安全各自的含义是什么 生产安全数据库录入 数据库的安全性及管理 数据库安全策略包含哪些 海淀数据库安全审计系统 建立农村房屋安全信息数据库 易用的数据库客户端支持安全管理 连接数据库失败ssl安全错误 数据库的锁怎样保障安全 北京服务器回收价格一览表 数据库费用在软件开发里吗 用软件开发过程中有趣的事 回收电脑服务器散热风扇公司 小米11从服务器获取to 电脑提示代理服务器 网页服务器有什么区别 军工行业软件开发 四川新一代网络技术服务设计 衡水学习软件开发 史上最好玩的娱乐服务器 县市网络安全宣传周活动方案 云帮邦网络技术有限公司 搭建团队知识库服务器 校园安全日网络安全总结 如何访问别的数据库 兖矿休闲网络安全工程师 把自己电脑当服务器 路由器完好但是显示服务器无响应 云服务器安装什么免费防护 计算机二级数据库知识点介绍 服务器突然不能用远程桌面登录了 东莞云软件开发电话 黑客基地网络安全培训 关于软件开发的名称 环信java服务器端 网页服务器有什么区别 考试时间表软件开发 什么是服务器通分 网页登录不了服务器
0