在Cube中,我希望根据特定维度和时间段获得度量的平均值

时间:2017-03-20 06:52:36

标签: mdx

在Cube中我希望得到基于特定维度和时间段的度量的平均值,但即使我应用sum,Avg或直接获取测量值,它也返回相同的结果,如果我遇到SQL则返回Same Query返回43行但在MDX查询中它只返回1行。多维数据集正在聚合度量值Query In SQL is As

 select Measure,[Dimension Name] from  datatable where dimension1key=1 and    countryKey=2 and regionKey=1 and channelKey=3  and timeperiod between(38,50) groupBy [Dimension Name],Measure
如果我写的话,在MDX中也是一样的

select {[Measure].[price] } on columns,non empty({[Dimension].[Dimanesion Name]}) on rows from (select {[Dimcountry].[country Name].[asia]} on columns from (select {[Dimchannel].[channel Name].[a]} on columns from (select [dimension1].[Dimension1Key].[1]} on columns from (select {[region].[region Name].[abc]} on columns from retaoauditcube))))

它只返回一行作为聚合值

2 个答案:

答案 0 :(得分:1)

您可以使用MDX AVG功能:

With 
Member [Measure].[AVG Price] as
AVG(
    [Date].[Calendar].[Day].Members,
    [Measure].[Price]
)

Select 
{[Measure].[Price],[Measure].[AVG Price]} on 0,
Non Empty [Dimension].[Hierarchy].[Attribute].Members on 1
From [retaoauditcube]
Where ([Dimcountry].[country Name].[asia],[Dimchannel].[channel Name].[a],[dimension1].[Dimension1Key].[1],[region].[region Name].[abc])

答案 1 :(得分:0)

c = cvpartition(Labels,'Holdout',0.3);
opts = statset('display','iter');
classf = @(train_data,train_labels,test_data,test_labels) ...
       sum(predict(fitcsvm(train_data,train_labels,'KernelFunction','rbf'), test_data) ~= test_labels); 
[fs,history] = sequentialfs(classf,Data,Labels,'cv',c,'options',opts)

所有这些查询都返回相同的输出

enter code here
With SET [ALL OTHERS] AS {   ({[Dim Timeperiod Derived].[Week Sequence].& 51]:[Dim Timeperiod Derived].[Week Sequence].&[51]},[Measures].[Price Per Pack])}member [Measures].[AVG Price] as AVG([ALL OTHERS])  MEMBER [Measures].[Current AVG Price] AS MAX(({[Dim Timeperiod Derived].[Week Sequence].&[51]:[Dim Timeperiod Derived].[Week Sequence].&[51]}),[Measures].[Price Per Pack])MEMBER [Measures].[Sum Price] AS AVG(({[Dim Timeperiod Derived].[Week Sequence].&[51]:[Dim Timeperiod Derived].[Week Sequence].&[51]}),[Measures].[Price Per Pack]) SELECT {[Measures].[Current AVG Price ],[Measures].[Sum Price] ,[Measures].[AVG Price]} ON COLUMNS ,NON EMPTY {[Dim Flavor Category].[Flavor Category RD].[Flavor Category RD].ALLMEMBERS,[Dim Flavor Category].[Flavor Category RD].[ALL OTHERS]} ON ROWS FROM (SELECT {[Dim Product Level].[Product Level Name].[FLAVOUR]} ON COLUMNS  FROM (SELECT {[Dim Brand].[Brand Name].[COCA COLA]} ON COLUMNS  FROM (SELECT {[Dim Category].[Category Name].[SPARKLING]} ON COLUMNS  FROM (SELECT {[Dim Channel].[Channel Name].[Total Channel]} ON COLUMNS  FROM (SELECT {[Dim Subchannel].[Subchannel Name].[Total]} ON COLUMNS FROM (SELECT {[Dim Subregion].[Subregion Name].[Total]} ON COLUMNS  FROM (SELECT {[Dim Region].[Region TD].[Total ID]} ON COLUMNS  FROM (SELECT {[Dim Country].[Country Name].[Indonesia]} ON COLUMNS FROM [Smartscan ASEAN])))))))) 

COLA 604314.177978516 604314.177978516 604314.177978516