我有一个像
这样的查询SELECT
NON EMPTY
{
[Measures].[ItemPrice]
}
ON COLUMNS ,
NON EMPTY
[DimItemView].[ItemName].[ItemName]
*[DimDateView].[MonthOfYear].[MonthOfYear]
*[DimCustomerView].[CustomerName].[CustomerName]
on rows
FROM [Model]
WHERE (
[DimCompanyView].[CompanyKey].&[smr],
[DimDateView].[Year].&[2017],
[DimCurrencyParam].[CurrencyCode].&[TL],
[DimItemView].[ItemKey].&[03001],--Filtered for single item, just for simplicity. Will be all ItemKey s
[DimDateView].[MonthName].[All])
输出
另一个查询
WITH
SET [AllItems] AS [DimItemView].[ItemName].[ItemName]
SET [AllMonths] AS [DimDateView].[MonthOfYear].[MonthOfYear]
SET [A] AS
Generate
(
{[AllItems]*[AllMonths] } AS s
,
s.current*
TopCount
(
[DimCustomerView].[CustomerName].[CustomerName]
,1
,[Measures].[ItemPrice]
)
)
SELECT
[Measures].[ItemPrice]
ON 0
,
[A] ON 1
FROM [Model]
WHERE (
[DimCompanyView].[CompanyKey].&[smr],
[DimDateView].[Year].&[2017],
[DimCurrencyParam].[CurrencyCode].&[TL],
[DimItemView].[ItemKey].&[03001], --Filtered for single item, just for simplicity. Will be all ItemKey s
[DimDateView].[MonthName].[All])
输出
我想要实现的是左连接2导致单个查询,但是对于相应组(ItemName和MonthOfYear)的左结果,每行包含TopPrice。期望的输出就像
任何帮助表示感谢。
答案 0 :(得分:0)
如果您需要计算一次,我会使用以下代码:
WITH
MEMBER [Measures].[GroupPrice] AS
([DimCustomerView].[CustomerName].[All],[Measures].[ItemPrice])
SELECT
NON EMPTY
{
[Measures].[ItemPrice],
[Measures].[GroupPrice]
}
ON COLUMNS ,
NON EMPTY
[DimItemView].[ItemName].[ItemName]
*[DimDateView].[MonthOfYear].[MonthOfYear]
*[DimCustomerView].[CustomerName].[CustomerName]
on rows
FROM [Model]
WHERE (
[DimCompanyView].[CompanyKey].&[smr],
[DimDateView].[Year].&[2017],
[DimCurrencyParam].[CurrencyCode].&[TL],
[DimItemView].[ItemKey].&[03001],--Filtered for single item, just for simplicity. Will be all ItemKey s
[DimDateView].[MonthName].[All])
答案 1 :(得分:0)
ITEMPRICE = ExwAmount / QtyKg
实际上下面的代码给了我预期的结果,但是太慢了。任何改进?
WITH
MEMBER [Measures].[GroupPrice] AS
max([DimCustomerView].[CustomerName].Members,[Measures].[ItemPrice])
SELECT
NON EMPTY
{
[Measures].[ItemPrice],
[Measures].[GroupPrice]
}
ON COLUMNS ,
NON EMPTY
[DimItemView].[ItemName].[ItemName]
*[DimDateView].[MonthOfYear].[MonthOfYear]
*[DimCustomerView].[CustomerName].[CustomerName]
having [Measures].[Fiili_Fiyat]<>0
on rows