Here is a simple schema with two dimensions and a fact with a measure.
CREATE TABLE DimThingType (
ThingTypeID int NOT NULL PRIMARY KEY,
ThingTypeDescription varchar(8) NOT NULL
)
CREATE TABLE DimThing (
ThingID int NOT NULL PRIMARY KEY,
ThingName varchar(8) NOT NULL
)
CREATE FactFacts (
FactID int NOT NULL PRIMARY KEY,
ThingID int NOT NULL,
ThingTypeID int NOT NULL,
Turnips int NOT NULL
)
Now in MDX we can sum the number of turnips for each thing type.
SELECT
NON EMPTY { [Measures].[Trunips] } ON COLUMNS,
NON EMPTY { ([ThingType].MEMBERS) } ON ROWS
FROM [Things]
Now if in this measure group I create a new measure called [Count of Facts]
with property Source.[Binding Type]
set to [Row binding]
and AggregateFunction
set to Count
then I can also count the number of things of each thing type.
SELECT
NON EMPTY { [Measures].[Trunips], [Measures].[Count of Facts] } ON COLUMNS,
NON EMPTY { ([ThingType].MEMBERS) } ON ROWS
FROM [Incidents]
Do I really have to add this new measure?
The number is the number of facts that were used in computing the value in the result cell, so can't I obtain that via the query? (If we were grouping in SQL then it would simply be COUNT(*)
.)
I absolutely can't get anything to work!