我有一个 CustomerToFactor 作为衡量标准和客户作为维度。现在我想创建一个类似这个 SQL 代码的 MDX 代码,但我做不到。因为 (WITH) 语句在 MDX 中有另一个含义。
with Total_Customer(
select cus_id
,sum(ctf_price) cus_total_price
from dbo.Customer
join dbo.CustomertoFactor on cus_id = ctf_cus_id
group by cus_id
)
select cus_id
,cus_name
,ctf_date
,ctf_price
,(cus_total_price / 100 * ctf_price) as Price_pro_customer
from dbo.Customer
join dbo.CustomertoFactor on cus_id = ctf_cus_id
join Total_Customer on Total_customer.cus_id = dbo.Customer.cus_id
SELECT NON EMPTY { [Measures].[ctf_date]
,[Measures].[ctf_price]
, (?) Price_pro_customer
} ON COLUMNS
,NON EMPTY {[Customer].[Customer - cus_name].[Customer - cus_name].ALLMEMBERS}
FROM [CustomerToFactor]
感谢您的回答。但它不起作用。实际上,我希望它针对您命名的每个名称进行分组。例如:对于名称 Alex,只需计算 Alex(100+300 = 400) 和 Group by 的总和。