Mondrain MDX 用于日期范围之间的记录,其中开始日期和结束日期是单独的列
Posted
技术标签:
【中文标题】Mondrain MDX 用于日期范围之间的记录,其中开始日期和结束日期是单独的列【英文标题】:Mondrain MDX for records between date range where start and end date being separate columns 【发布时间】:2017-04-28 06:36:48 【问题描述】:我想在相同维度的两列之间搜索日期。列名称是开始日期和结束日期。我尝试了一切,以下查询给了我这个错误:蒙德里安错误:内部错误:无法推断函数调用的类型':'
MDX 查询:
WITH
SET [~ROWS] AS
Hierarchize
(
[Location_Cluster.default].[All Location_Cluster.defaults]
,[Location_Cluster.default].[Location_Cluster].MEMBERS
)
MEMBER [Measures].[QTY Percent] AS
[Measures].[Total_Quantity]
/
(
[Measures].[Total_Quantity]
,[Location_Cluster.default].[All Location_Cluster.defaults]
)
,format_string = '0.00%'
MEMBER [Measures].[Revenue Percent] AS
[Measures].[Total_Revenue]
/
(
[Measures].[Total_Revenue]
,[Location_Cluster.default].[All Location_Cluster.defaults]
)
,format_string = '0.00%'
MEMBER [Measures].[Margin Percent] AS
[Measures].[Total_Margin]
/
(
[Measures].[Total_Margin]
,[Location_Cluster.default].[All Location_Cluster.defaults]
)
,format_string = '0.00%'
SELECT
NON EMPTY
[Measures].[Sku_Count]
,[Measures].[Total_Quantity]
,[Measures].[QTY Percent]
,[Measures].[Total_Revenue]
,[Measures].[Revenue Percent]
,[Measures].[Total_Margin]
,[Measures].[Margin Percent]
ON COLUMNS
,NON EMPTY
[~ROWS] ON ROWS
FROM [APCS_SALES_CUBE]
WHERE
(
[Date].[Start_Date].&[2017-01-01] : NULL
,NULL : [Date].[End_Date].&[2017-03-01]
,[Cluster.Cluster_Id].[2]
,[Taxonomy.default].[Taxonomy_ID].[3]
,[Company.Company_Name].[Compnay_Name].[1]
);
我按照以下链接解决了这个问题。但不知道如何在 Mondrian MDX 中应用指定函数
https://ask.sqlservercentral.com/questions/95478/mdx-for-records-between-date-range-where-start-and.html#answer-142811
https://www.purplefrogsystems.com/blog/2013/04/mdx-between-start-date-and-end-date/#comment-1981
【问题讨论】:
【参考方案1】:您的查询格式不正确。您需要设置超出要切片的范围。这是一个例子:
WITH SET [~ROWS] AS
($dateFromParameter : $dateToParameter)
MEMBER Measures.[number] as
FORMAT([date].[godina].CurrentMember.PROPERTIES("datum"), "dd.mm.yyyy")
SET [ROOT] AS
FILTER([ORG].[org_id].Members, [ORG].[org_id].currentmember.parent.parent=[ORG].[org_id].currentmember.parent)
SELECT
NON EMPTY [Measures].[total], Measures.[number] ON COLUMNS,
NON EMPTY [ROOT] * [~ROWS] ON ROWS
FROM [svcs]
【讨论】:
以上是关于Mondrain MDX 用于日期范围之间的记录,其中开始日期和结束日期是单独的列的主要内容,如果未能解决你的问题,请参考以下文章