每个共同维度成员的计算量度

时间:2018-08-14 11:18:48

标签: ssas sql-server-2016 tabular ssas-tabular

给出下表:

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])
);

因此,Personeel模式中的两个表都引用了Dimensie模式中的两个表。

我根据这些表格通过以下措施生成了一个SSAS tabular项目:

Contracturen := SUM('Contractuele uren'[Contractuele uren])
Uren/FTE     := SUM('Werklast uren'[Werklast uren])
Contract FTE := 'Contractuele uren'[Contracturen]/'Werklast uren'[Uren/FTE]

这给了我以下结果(行上[Dimensie].[Datum].[Maand],列上[Dimensie].[Cao].[Cao business key]

enter image description here

每个月都可以。但是,总计是两个和的除法,而我希望它是成员3645的小计的和。

如何更改指标Contract FTE的定义以实现此目标?

1 个答案:

答案 0 :(得分:1)

在总结之前,使用迭代器对各个成员进行除法:

Contract FTE := 
    SUMX(
        VALUES('Cao'[Cao business key]); 
        DIVIDE('Contractuele uren'[Contracturen]; 'Werklast uren'[Uren/FTE])
    )