Given the following tables:
CREATE TABLE [Dimensie].[Cao]
(
[Cao key] INT NOT NULL IDENTITY(1,1),
[Cao business key] NVARCHAR(255) NOT NULL,
CONSTRAINT [PK Cao] PRIMARY KEY ([Cao key]),
CONSTRAINT [UC Cao business key] UNIQUE ([Cao business key])
);
CREATE TABLE [Dimensie].[Datum]
(
[Datum key] INT NOT NULL,
[Datum business key] DATETIME NOT NULL,
[Jaar] INT NOT NULL,
[Maand] INT NOT NULL,
[Dag van de maand] INT NOT NULL,
[Datum] NVARCHAR(255) NOT NULL
CONSTRAINT [PK Datum] PRIMARY KEY ([Datum key]),
CONSTRAINT [UC Datum business key] UNIQUE ([Datum business key])
);
CREATE TABLE [Personeel].[Contractuele uren]
(
[Datum key] INT NOT NULL,
[Cao key] INT NOT NULL,
[Contractuele uren] NUMERIC(15,6) NOT NULL,
CONSTRAINT [FK Contractuele uren Datum] FOREIGN KEY ([Datum key]) REFERENCES [Dimensie].[Datum] ([Datum key]),
CONSTRAINT [FK Contractuele uren Cao] FOREIGN KEY ([Cao key]) REFERENCES [Dimensie].[Cao] ([Cao key]),
CONSTRAINT [UC Contractuele uren] UNIQUE ([Datum key], [Cao key])
);
CREATE TABLE [Personeel].[Werklast uren]
(
[Datum key] INT NOT NULL,
[Cao key] INT NOT NULL,
[Werklast uren] NUMERIC(15,6) NOT NULL,
CONSTRAINT [FK Werklast uren Datum] FOREIGN KEY ([Datum key]) REFERENCES [Dimensie].[Datum] ([Datum key]),
CONSTRAINT [FK Werklast uren Cao] FOREIGN KEY ([Cao key]) REFERENCES [Dimensie].[Cao] ([Cao key])
);
So both tables in the Personeel
schema are referencing both tables in the Dimensie
schema.
I have generated a SSAS tabular
project based on these tables with the following measures:
Contracturen := SUM('Contractuele uren'[Contractuele uren])
Uren/FTE := SUM('Werklast uren'[Werklast uren])
Contract FTE := 'Contractuele uren'[Contracturen]/'Werklast uren'[Uren/FTE]
This gives me the following result ([Dimensie].[Datum].[Maand]
on rows, [Dimensie].[Cao].[Cao business key]
on columns):
Which is fine per month. However, the grandtotal is a division of both sums, while I'd like it to be the sum of the subtotals of member 36
and 45
.
How can I change the definition of my measure Contract FTE
to achieve this?
Use an iterator to perform the division at the individual members, before summing up:
Contract FTE :=
SUMX(
VALUES('Cao'[Cao business key]);
DIVIDE('Contractuele uren'[Contracturen]; 'Werklast uren'[Uren/FTE])
)