且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何计算MDX中组的总和?

更新时间:2022-11-26 20:32:23

如果您只想显示卖方和城市的总人数,可以使用下面的查询。

If you just want to show the sum of population by seller and cities, you can use something like the query below.

SELECT Measures.Population 
ON 0,
FILTER(Seller.SellerName.CHILDREN * City.City.CHILDREN, Measures.[Sales Amount] > 0)
ON 1
FROM [YourCube]

SELECT Measures.Population 
ON 0,
(Seller.SellerName.CHILDREN * City.City.CHILDREN)
HAVING Measures.[Sales Amount] > 0
ON 1
FROM [YourCube]

显然,你必须用多维数据集中的实际尺寸名称替换。

Obviously, you would have to substitute with the actual dimension names from cube.

编辑:

如果你只想要总和在卖家销售的所有城市中,尝试以下代码

//Build a set of cities
with set CitiesForSeller as
exists(City.City.CHILDREN, strtoset('Seller.SellerName.&[SomeName]'), "<<Name of the measure group which has the population measure>>")

//Get the sum of population in all the cities combined
member measures.SumOfPopulation as
sum(CitiesForSeller,Measures.Population)

select measures.SumOfPopulation on 0,
CitiesForSeller 
having measures.SumOfPopulation > 0
on 1
from [YourCube]