我有一个带有一个事实表和四个维度(日期,产品,商店和国家/地区)的多维数据集。维度通常使用主外键连接到事实。
我想查询此模型以获取唯一的维度信息(即我不需要任何事实表列)。例如,我想查看所有国家/地区的所有商店的状态(ACTIVE / INACTIVE等)。
我写的查询是
WITH
MEMBER [Dim shop.Shop id].[Shop count] AS
Count([Dim shop.Shop id].Members, EXCLUDEEMPTY) --select the count of shop members
SET [~ROWS_Dim country.Country name] AS
{[Dim country.Country name].[Country name].Members} --All countries
SET [~ROWS_Dim shop.Status] AS
{[Dim shop.Status].[Status].Members} --All shop statuses
SELECT
NON EMPTY [Dim shop.Shop id].[Shop count] ON COLUMNS,
NON EMPTY NonEmptyCrossJoin([~ROWS_Dim country.Country name], [~ROWS_Dim shop.Status]) ON ROWS
FROM [cube]
WHERE ({[Dim shop.Date to].[2199-12-31 22:59:59.999],[Dim shop.Date to].[2199-12-31 23:59:59.999]}) --Slicing to get only currently inventoried shops
架构如下所示
<Schema name="cube">
<Dimension name="Dim country">
<Hierarchy name="Cid" hasAll="true" primaryKey="cid">
<Table name="dim_country" schema="dw_pp"/>
<Level name="Cid" uniqueMembers="false" column="cid" type="Numeric">
</Level>
</Hierarchy>
<Hierarchy name="Country code name" hasAll="true" primaryKey="cid">
<Table name="dim_country" schema="dw_pp"/>
<Level name="Country code name" uniqueMembers="false" column="country_code_name" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Country currency" hasAll="true" primaryKey="cid">
<Table name="dim_country" schema="dw_pp"/>
<Level name="Country currency" uniqueMembers="false" column="country_currency" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Country ga id" hasAll="true" primaryKey="cid">
<Table name="dim_country" schema="dw_pp"/>
<Level name="Country ga id" uniqueMembers="false" column="country_ga_id" type="Numeric">
</Level>
</Hierarchy>
<Hierarchy name="Country name" hasAll="true" primaryKey="cid">
<Table name="dim_country" schema="dw_pp"/>
<Level name="Country name" uniqueMembers="false" column="country_name" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Date from" hasAll="true" primaryKey="cid">
<Table name="dim_country" schema="dw_pp"/>
<Level name="Date from" uniqueMembers="false" column="date_from">
</Level>
</Hierarchy>
<Hierarchy name="Date to" hasAll="true" primaryKey="cid">
<Table name="dim_country" schema="dw_pp"/>
<Level name="Date to" uniqueMembers="false" column="date_to">
</Level>
</Hierarchy>
<Hierarchy name="Version" hasAll="true" primaryKey="cid">
<Table name="dim_country" schema="dw_pp"/>
<Level name="Version" uniqueMembers="false" column="version" type="Numeric">
</Level>
</Hierarchy>
</Dimension>
<Dimension name="Dim date">
<Hierarchy name="Calendar month" hasAll="true" primaryKey="date_key">
<Table name="dim_date" schema="dw_pp"/>
<Level name="Calendar month" uniqueMembers="false" column="calendar_month" type="Numeric">
</Level>
</Hierarchy>
<Hierarchy name="Calendar month name" hasAll="true" primaryKey="date_key">
<Table name="dim_date" schema="dw_pp"/>
<Level name="Calendar month name" uniqueMembers="false" column="calendar_month_name" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Calendar week" hasAll="true" primaryKey="date_key">
<Table name="dim_date" schema="dw_pp"/>
<Level name="Calendar week" uniqueMembers="false" column="calendar_week" type="Numeric">
</Level>
</Hierarchy>
<Hierarchy name="Calendar year" hasAll="true" primaryKey="date_key">
<Table name="dim_date" schema="dw_pp"/>
<Level name="Calendar year" uniqueMembers="false" column="calendar_year" type="Numeric">
</Level>
</Hierarchy>
<Hierarchy name="Date" hasAll="true" primaryKey="date_key">
<Table name="dim_date" schema="dw_pp"/>
<Level name="Date" uniqueMembers="false" column="date">
</Level>
</Hierarchy>
<Hierarchy name="Date key" hasAll="true" primaryKey="date_key">
<Table name="dim_date" schema="dw_pp"/>
<Level name="Date key" uniqueMembers="false" column="date_key" type="Numeric">
</Level>
</Hierarchy>
<Hierarchy name="Day of month" hasAll="true" primaryKey="date_key">
<Table name="dim_date" schema="dw_pp"/>
<Level name="Day of month" uniqueMembers="false" column="day_of_month" type="Numeric">
</Level>
</Hierarchy>
<Hierarchy name="Day of week" hasAll="true" primaryKey="date_key">
<Table name="dim_date" schema="dw_pp"/>
<Level name="Day of week" uniqueMembers="false" column="day_of_week" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Day of week name" hasAll="true" primaryKey="date_key">
<Table name="dim_date" schema="dw_pp"/>
<Level name="Day of week name" uniqueMembers="false" column="day_of_week_name" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Day of year" hasAll="true" primaryKey="date_key">
<Table name="dim_date" schema="dw_pp"/>
<Level name="Day of year" uniqueMembers="false" column="day_of_year" type="Numeric">
</Level>
</Hierarchy>
<Hierarchy name="Quarter" hasAll="true" primaryKey="date_key">
<Table name="dim_date" schema="dw_pp"/>
<Level name="Quarter" uniqueMembers="false" column="quarter" type="String">
</Level>
</Hierarchy>
</Dimension>
<Dimension name="Dim product">
<Hierarchy name="Brand" hasAll="true" primaryKey="product_pk">
<Table name="dim_product" schema="dw_pp"/>
<Level name="Brand" uniqueMembers="false" column="brand" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Category id" hasAll="true" primaryKey="product_pk">
<Table name="dim_product" schema="dw_pp"/>
<Level name="Category id" uniqueMembers="false" column="category_id" type="Numeric">
</Level>
</Hierarchy>
<Hierarchy name="Category name" hasAll="true" primaryKey="product_pk">
<Table name="dim_product" schema="dw_pp"/>
<Level name="Category name" uniqueMembers="false" column="category_name" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Code" hasAll="true" primaryKey="product_pk">
<Table name="dim_product" schema="dw_pp"/>
<Level name="Code" uniqueMembers="false" column="code" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Created" hasAll="true" primaryKey="product_pk">
<Table name="dim_product" schema="dw_pp"/>
<Level name="Created" uniqueMembers="false" column="created">
</Level>
</Hierarchy>
<Hierarchy name="Created by" hasAll="true" primaryKey="product_pk">
<Table name="dim_product" schema="dw_pp"/>
<Level name="Created by" uniqueMembers="false" column="created_by" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Date from" hasAll="true" primaryKey="product_pk">
<Table name="dim_product" schema="dw_pp"/>
<Level name="Date from" uniqueMembers="false" column="date_from">
</Level>
</Hierarchy>
<Hierarchy name="Date to" hasAll="true" primaryKey="product_pk">
<Table name="dim_product" schema="dw_pp"/>
<Level name="Date to" uniqueMembers="false" column="date_to">
</Level>
</Hierarchy>
<Hierarchy name="Ean" hasAll="true" primaryKey="product_pk">
<Table name="dim_product" schema="dw_pp"/>
<Level name="Ean" uniqueMembers="false" column="ean" type="Numeric">
</Level>
</Hierarchy>
<Hierarchy name="Image location high" hasAll="true" primaryKey="product_pk">
<Table name="dim_product" schema="dw_pp"/>
<Level name="Image location high" uniqueMembers="false" column="image_location_high" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Image location low" hasAll="true" primaryKey="product_pk">
<Table name="dim_product" schema="dw_pp"/>
<Level name="Image location low" uniqueMembers="false" column="image_location_low" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Image location thumb" hasAll="true" primaryKey="product_pk">
<Table name="dim_product" schema="dw_pp"/>
<Level name="Image location thumb" uniqueMembers="false" column="image_location_thumb" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Last modified by price" hasAll="true" primaryKey="product_pk">
<Table name="dim_product" schema="dw_pp"/>
<Level name="Last modified by price" uniqueMembers="false" column="last_modified_by_price" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Last modifiedby product" hasAll="true" primaryKey="product_pk">
<Table name="dim_product" schema="dw_pp"/>
<Level name="Last modifiedby product" uniqueMembers="false" column="last_modifiedby_product" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Level0 parent category id" hasAll="true" primaryKey="product_pk">
<Table name="dim_product" schema="dw_pp"/>
<Level name="Level0 parent category id" uniqueMembers="false" column="level0_parent_category_id" type="Numeric">
</Level>
</Hierarchy>
<Hierarchy name="Level0 parent category name" hasAll="true" primaryKey="product_pk">
<Table name="dim_product" schema="dw_pp"/>
<Level name="Level0 parent category name" uniqueMembers="false" column="level0_parent_category_name" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Level1 parent category id" hasAll="true" primaryKey="product_pk">
<Table name="dim_product" schema="dw_pp"/>
<Level name="Level1 parent category id" uniqueMembers="false" column="level1_parent_category_id" type="Numeric">
</Level>
</Hierarchy>
<Hierarchy name="Level1 parent category name" hasAll="true" primaryKey="product_pk">
<Table name="dim_product" schema="dw_pp"/>
<Level name="Level1 parent category name" uniqueMembers="false" column="level1_parent_category_name" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Manufacturer id" hasAll="true" primaryKey="product_pk">
<Table name="dim_product" schema="dw_pp"/>
<Level name="Manufacturer id" uniqueMembers="false" column="manufacturer_id" type="Numeric">
</Level>
</Hierarchy>
<Hierarchy name="Modified product" hasAll="true" primaryKey="product_pk">
<Table name="dim_product" schema="dw_pp"/>
<Level name="Modified product" uniqueMembers="false" column="modified_product">
</Level>
</Hierarchy>
<Hierarchy name="Price" hasAll="true" primaryKey="product_pk">
<Table name="dim_product" schema="dw_pp"/>
<Level name="Price" uniqueMembers="false" column="price" type="Numeric">
</Level>
</Hierarchy>
<Hierarchy name="Price with shipping" hasAll="true" primaryKey="product_pk">
<Table name="dim_product" schema="dw_pp"/>
<Level name="Price with shipping" uniqueMembers="false" column="price_with_shipping" type="Numeric">
</Level>
</Hierarchy>
<Hierarchy name="Product currency code" hasAll="true" primaryKey="product_pk">
<Table name="dim_product" schema="dw_pp"/>
<Level name="Product currency code" uniqueMembers="false" column="product_currency_code" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Product id" hasAll="true" primaryKey="product_pk">
<Table name="dim_product" schema="dw_pp"/>
<Level name="Product id" uniqueMembers="false" column="product_id" type="Numeric">
</Level>
</Hierarchy>
<Hierarchy name="Product info id" hasAll="true" primaryKey="product_pk">
<Table name="dim_product" schema="dw_pp"/>
<Level name="Product info id" uniqueMembers="false" column="product_info_id" type="Numeric">
</Level>
</Hierarchy>
<Hierarchy name="Product name" hasAll="true" primaryKey="product_pk">
<Table name="dim_product" schema="dw_pp"/>
<Level name="Product name" uniqueMembers="false" column="product_name" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Product page type" hasAll="true" primaryKey="product_pk">
<Table name="dim_product" schema="dw_pp"/>
<Level name="Product page type" uniqueMembers="false" column="product_page_type" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Product pk" hasAll="true" primaryKey="product_pk">
<Table name="dim_product" schema="dw_pp"/>
<Level name="Product pk" uniqueMembers="false" column="product_pk" type="Numeric">
</Level>
</Hierarchy>
<Hierarchy name="Quality" hasAll="true" primaryKey="product_pk">
<Table name="dim_product" schema="dw_pp"/>
<Level name="Quality" uniqueMembers="false" column="quality" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Shop active" hasAll="true" primaryKey="product_pk">
<Table name="dim_product" schema="dw_pp"/>
<Level name="Shop active" uniqueMembers="false" column="shop_active" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Shop id" hasAll="true" primaryKey="product_pk">
<Table name="dim_product" schema="dw_pp"/>
<Level name="Shop id" uniqueMembers="false" column="shop_id" type="Numeric">
</Level>
</Hierarchy>
<Hierarchy name="Shop paying" hasAll="true" primaryKey="product_pk">
<Table name="dim_product" schema="dw_pp"/>
<Level name="Shop paying" uniqueMembers="false" column="shop_paying" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Status product" hasAll="true" primaryKey="product_pk">
<Table name="dim_product" schema="dw_pp"/>
<Level name="Status product" uniqueMembers="false" column="status_product" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Tstamp" hasAll="true" primaryKey="product_pk">
<Table name="dim_product" schema="dw_pp"/>
<Level name="Tstamp" uniqueMembers="false" column="tstamp">
</Level>
</Hierarchy>
<Hierarchy name="Version" hasAll="true" primaryKey="product_pk">
<Table name="dim_product" schema="dw_pp"/>
<Level name="Version" uniqueMembers="false" column="version" type="Numeric">
</Level>
</Hierarchy>
</Dimension>
<Dimension name="Dim shop">
<Hierarchy name="Ac id" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Ac id" uniqueMembers="false" column="ac_id" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Ac type" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Ac type" uniqueMembers="false" column="ac_type" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Account status" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Account status" uniqueMembers="false" column="account_status" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Afl network" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Afl network" uniqueMembers="false" column="afl_network" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Afl param" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Afl param" uniqueMembers="false" column="afl_param" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Capping" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Capping" uniqueMembers="false" column="capping" type="Numeric">
</Level>
</Hierarchy>
<Hierarchy name="Co id" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Co id" uniqueMembers="false" column="co_id" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Co name" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Co name" uniqueMembers="false" column="co_name" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Co type" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Co type" uniqueMembers="false" column="co_type" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Contract number" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Contract number" uniqueMembers="false" column="contract_number" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Contract type" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Contract type" uniqueMembers="false" column="contract_type" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Country code" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Country code" uniqueMembers="false" column="country_code" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Cpc" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Cpc" uniqueMembers="false" column="cpc" type="Numeric">
</Level>
</Hierarchy>
<Hierarchy name="Cpc earning" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Cpc earning" uniqueMembers="false" column="cpc_earning" type="Numeric">
</Level>
</Hierarchy>
<Hierarchy name="Cpo" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Cpo" uniqueMembers="false" column="cpo" type="Numeric">
</Level>
</Hierarchy>
<Hierarchy name="Created" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Created" uniqueMembers="false" column="created">
</Level>
</Hierarchy>
<Hierarchy name="Currency" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Currency" uniqueMembers="false" column="currency" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Date from" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Date from" uniqueMembers="false" column="date_from">
</Level>
</Hierarchy>
<Hierarchy name="Date to" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Date to" uniqueMembers="false" column="date_to">
</Level>
</Hierarchy>
<Hierarchy name="Description" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Description" uniqueMembers="false" column="description" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Image location high" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Image location high" uniqueMembers="false" column="image_location_high" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Image location low" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Image location low" uniqueMembers="false" column="image_location_low" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Image location thumb" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Image location thumb" uniqueMembers="false" column="image_location_thumb" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Last modifiedby" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Last modifiedby" uniqueMembers="false" column="last_modifiedby" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Modified" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Modified" uniqueMembers="false" column="modified">
</Level>
</Hierarchy>
<Hierarchy name="No deep links" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="No deep links" uniqueMembers="false" column="no_deep_links" type="Boolean">
</Level>
</Hierarchy>
<Hierarchy name="Opening hours" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Opening hours" uniqueMembers="false" column="opening_hours" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Pay status" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Pay status" uniqueMembers="false" column="pay_status" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Score" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Score" uniqueMembers="false" column="score" type="Numeric">
</Level>
</Hierarchy>
<Hierarchy name="Shipping details" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Shipping details" uniqueMembers="false" column="shipping_details" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Shipping fee" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Shipping fee" uniqueMembers="false" column="shipping_fee" type="Numeric">
</Level>
</Hierarchy>
<Hierarchy name="Shop id" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Shop id" uniqueMembers="false" column="shop_id" type="Numeric">
</Level>
</Hierarchy>
<Hierarchy name="Shop name" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Shop name" uniqueMembers="false" column="shop_name" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Shop pk" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Shop pk" uniqueMembers="false" column="shop_pk" type="Numeric">
</Level>
</Hierarchy>
<Hierarchy name="Start date" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Start date" uniqueMembers="false" column="start_date">
</Level>
</Hierarchy>
<Hierarchy name="Status" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Status" uniqueMembers="false" column="status" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Target country" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Target country" uniqueMembers="false" column="target_country" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Type" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Type" uniqueMembers="false" column="type" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Url" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Url" uniqueMembers="false" column="url" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Url policy" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Url policy" uniqueMembers="false" column="url_policy" type="String">
</Level>
</Hierarchy>
<Hierarchy name="Version" hasAll="true" primaryKey="shop_pk">
<Table name="dim_shop" schema="dw_pp"/>
<Level name="Version" uniqueMembers="false" column="version" type="Numeric">
</Level>
</Hierarchy>
</Dimension>
<Cube name="cube">
<Table name="fc_analytics" schema="dw_pp"/>
<DimensionUsage name="Dim country" source="Dim country" foreignKey="country_fk"/>
<DimensionUsage name="Dim date" source="Dim date" foreignKey="date_fk"/>
<DimensionUsage name="Dim product" source="Dim product" foreignKey="product_fk"/>
<DimensionUsage name="Dim shop" source="Dim shop" foreignKey="shop_fk"/>
<Measure name="Country fk" column="country_fk" aggregator="sum" formatString="#"/>
<Measure name="Date fk" column="date_fk" aggregator="sum" formatString="#"/>
<Measure name="Product fk" column="product_fk" aggregator="sum" formatString="#"/>
<Measure name="Ser id" column="ser_id" aggregator="sum" formatString="#"/>
<Measure name="Shop fk" column="shop_fk" aggregator="sum" formatString="#"/>
<Measure name="Measure1" column="M1" aggregator="sum" formatString="#"/>
<Measure name="Measure2" column="M2" aggregator="sum" formatString="#"/>
<Measure name="Measure3" column="M3" aggregator="sum" formatString="#"/>
</Cube>
</Schema>**strong text**
查询运行。但价值观不正确。我在这里错过了什么吗?
答案 0 :(得分:0)
这让我觉得有些奇怪:
MEMBER [Dim shop.Shop id].[Shop count] AS
Count([Dim shop.Shop id].Members, EXCLUDEEMPTY)
它看起来像一个衡量指标,为什么不将它添加到[Measures]
层次结构?
MEMBER [Measures].[Shop count] AS
Count([Dim shop.Shop id].Members, EXCLUDEEMPTY)
您可能需要在度量中添加一些上下文:
MEMBER [Measures].[Shop count] AS
Count(
nonempty(
[Dim shop.Shop id].Members
,{[~ROWS_Dim country].currentmember, [~ROWS_Dim shop].currentmember})
)
)
我不确定标准mdx
mondrian会使用什么,但关键字existing
以下情况会更好:
MEMBER [Measures].[Shop count] AS
Count(
nonempty(
EXISTING [Dim shop.Shop id].Members
,{[~ROWS_Dim country].currentmember, [~ROWS_Dim shop].currentmember})
)
)
答案 1 :(得分:0)
你应该尝试Hierarchize([DimShops]。[Shop Id] .members)
答案 2 :(得分:0)
问题在于我的事实表。显然,NonEmptyCrossJoin()首先扫描事实表并排除没有事实表条目的维度条目(这不是我想要的。我想独立查询维度)
This解释了使用NonEmptyCrossJoin()
的危险我使用了FILTER(CROSSJOIN(,)AS S,而不是IsEmpty(S.Current))。