mdx

Counting the number of facts in a cell in MDX

依然范特西╮ 提交于 2020-03-25 18:39:54
问题 Here is a simple schema with two dimensions and a fact with a measure. CREATE TABLE DimThingType ( ThingTypeID int NOT NULL PRIMARY KEY, ThingTypeDescription varchar(8) NOT NULL ) CREATE TABLE DimThing ( ThingID int NOT NULL PRIMARY KEY, ThingName varchar(8) NOT NULL ) CREATE FactFacts ( FactID int NOT NULL PRIMARY KEY, ThingID int NOT NULL, ThingTypeID int NOT NULL, Turnips int NOT NULL ) Now in MDX we can sum the number of turnips for each thing type . SELECT NON EMPTY { [Measures].[Trunips

Counting the number of facts in a cell in MDX

怎甘沉沦 提交于 2020-03-25 18:39:11
问题 Here is a simple schema with two dimensions and a fact with a measure. CREATE TABLE DimThingType ( ThingTypeID int NOT NULL PRIMARY KEY, ThingTypeDescription varchar(8) NOT NULL ) CREATE TABLE DimThing ( ThingID int NOT NULL PRIMARY KEY, ThingName varchar(8) NOT NULL ) CREATE FactFacts ( FactID int NOT NULL PRIMARY KEY, ThingID int NOT NULL, ThingTypeID int NOT NULL, Turnips int NOT NULL ) Now in MDX we can sum the number of turnips for each thing type . SELECT NON EMPTY { [Measures].[Trunips

MDX 函数参考 (MDX)--MSDN

本小妞迷上赌 提交于 2020-03-16 07:13:54
MDX 函数参考 (MDX) Microsoft SQL Server Analysis Services 允许在多维表达式 (MDX) 语法中使用函数。函数可以在任何有效的 MDX 语句中使用,并且经常用于查询、自定义汇总定义以及其他计算。 本节介绍 Analysis Services 附带的 MDX 函数。 可以使用下面这些表按返回值的类别来查找函数,也可以从按字母顺序排列的目录中按名称来选择函数。 数组函数 函数 说明 SetToArray (MDX) 将一个或多个集转换为数组,以便在用户定义函数中使用。 层次结构函数 函数 说明 Hierarchy (MDX) 返回包含指定的成员或级别的层次结构。 Dimension (MDX) 返回包含指定的成员、级别或层次结构的维度。 Dimensions (MDX) 返回由数值表达式或字符串表达式指定的层次结构。 级别函数 函数 说明 Level (MDX) 返回成员的级别。 Levels (MDX) 返回由数值表达式指定了在维度或层次结构中位置的级别,或返回由字符串表达式指定了名称的级别。 逻辑函数 函数 说明 IsAncestor (MDX) 返回一个指定成员是否为另一个指定成员的祖先。 IsEmpty (MDX) 返回表达式的计算结果是否为空单元值。 IsGeneration (MDX) 返回指定成员是否处于指定的代中。

利用.NET扩展MDX存储过程

跟風遠走 提交于 2020-03-16 07:13:18
  SSAS的MDX脚本提供了强大的数据分析查询功能,然而在实际使用中同样会遇到一些问题使得用MDX来表达比较困难,因为MDX并不能提供满足所有数据分析需求的函数,这个时候可以尝试通过基于.NET的存储过程以编程的方式来完成我们特定的功能需求。基于.NET的MDX存储过程支持所有基于.NET平台的编程语言。可以通过创建一个包含所需功能的.NET程序集,然后将这个程序集加载到分析服务器或某个多维数据库中,最后就可以在MDX中引用这个.NET编写的存储过程了。 CustomAnalysisAssembly namespace CustomAnalysisAssembly { public class SPDemo { public static double SalesDifference( double firstVal, double secondVal) { return secondVal – firstVal; } } }   上面是用C#实现的一个简单Demo存储过程,用于处理两个值的差。上面使用的是一个静态函数来实现具体功能,而实际上静态函数并非唯一的选择,也可以使用非静态的方法。问题在于在MDX中引用非静态方法的时候,可能会造成服务器多次创建同一个对象,造成资源浪费。相反,如果使用静态函数,服务器就不会为其创建实例对象而是直接使用这个静态函数。所以在用

MDX学习——初始MDX

烂漫一生 提交于 2020-03-16 07:12:27
认识MDX 1, AS 2005 CUBE结构 在认识MDX之前先来认识下AS 2005 CUBE结构。如下图,Cube的结构里有维度和量值,而维度下有阶层(属性),阶层下有层级,每个层级有许多成员。 2,MDX 多维运算式(MultiDimensional eXpressions,MDX),是以陈述式为基础的指令码语言,用来在SSAS中定义、使用和截取多维体内的数据。 3,MDX多维查询语法 MDX语法 WITH [< 导出成员 >] [< 自定义 命名 集 >] [< 单元格计 算 >] SELECT <Tuple> ON < 轴 > [,<Tuple> ON < 轴 >…] FROM [<Cube 名称 >] WHERE [<Slicer 切片 >] 导出成员语法 MEMBER < 成员 名 称 > AS '< 计算公式 >' [,SOLVE_ORDER = < 解决 顺 序 >] [,<cell_property> = <value_expression>] [,FORMAT_STRING = < 显示格式 >] 命名集语法 SET < 集合名称 > AS '< 成员 集合 >' 单元格计算语法 CELL CALCULATION < 单元格名称 > FOR '(<calculation_subcube>)' AS '<calculation_formula>' [,

How to Get Current Year with MDX Query?

痞子三分冷 提交于 2020-02-07 08:21:05
问题 I have little thing about MDX. Is there any way to get current year from the system/server with MDX query? I didn't have any dimension related to date or something like that. Regards. 回答1: Create a member and define it as 'YEAR(NOW())' Member [Measures].[Current Year] as 'YEAR(NOW())' Here is a more complete sample -- The First Calculated member is the value of NOW() WITH MEMBER [Measures].[Full Date] as 'NOW()' -- The Second Calculated Member is the Day part of the first calculated member.

How to build a dynamic MDX formula for a calculated member?

試著忘記壹切 提交于 2020-02-05 08:37:07
问题 I am trying to create a Calculated Member to get a sum up to last week. No problem to get the week value (I need it to be two digits i.e. '05', so adding 100-1 ) with Member [Measures].Week as 'right(str(int(99+datepart ( ''ww'', Now()))),2)' -- That works as expected member [Measures].SalesUpToWeek as 'strtomember( "aggregate(periodstodate([Dim].[2015],[Dim].[2015].[" + ([Measures].Week) + "]),[Measures].[Sales])")' I get the literal value aggregate( periodstodate([Dim].[2015],[Dim].[2015].

MDX - Filter multiple dimensions

…衆ロ難τιáo~ 提交于 2020-02-04 04:00:33
问题 I'm trying to form an MDX query such that it returns only the combinations of two dimensions where a measure meets a certain criteria. I thought this would be pretty straight forward using the FILTER function, i.e. SELECT NON EMPTY FILTER({[Program].[ByRegion].[Program] * [Performance Metric].[Metric].CHILDREN }, [Measures].[Point Percentage] < .95) ON ROWS, NON EMPTY ( HIERARCHIZE([Calendar Period].[Y-Q-M].[Month of Quarter].&[3]&[1]&[2009]) , [Measures].[Point Percentage] )ON COLUMNS FROM

Best Way to Access MS Analysis Services Cube from Java

余生颓废 提交于 2020-01-29 13:29:10
问题 I want to issue MDX against a MSAS cube from a Java client. What connectivity approaches have proven to be reliable for this? 回答1: FWIW I'm using olap4j as the Java client against a MSAS server fronted up by msmdpump.dll. Seems so far to work OK. 回答2: Check out http://mondrian.pentaho.org/. This is an OLAP sever with MDX/XMLA support. I understand that what you need is a client but check in the JSP examples that comes with the sever. One example involve MDX queries over XMLA and I think this

A List of Characters That Will Break OLAP Cubes

大城市里の小女人 提交于 2020-01-25 10:11:08
问题 Today I received a curious error in one of the OLAP cube I was working on. When trying to access it from SSAS or from a external connection in Excel, I received an error similar to what is described below: '', hexadecimal value 0x1A, is an invalid character. Line 1, position 325042770. (System.Xml) Not sure why this special character was displayed as a "->" symbol, but after exporting the error message to text I determined this it was the "SUB" character. Apparently it was a "invalid