获取最近三个月的发票数量?
Get count of invoices for last three months?
谢谢大家。这是我的 MDX 查询和这个 returns 2015 年 3 月生成的发票计数,非常有用!
WITH
SET [mySet] AS
[Customer].[Store Group].[Store Group] * {[Measures].[Sales #]}
MEMBER [Measures].[setDistCount] AS
DistinctCount([mySet])
SELECT
{
[Measures].[Sales #]
} ON 0
,NON EMPTY
[Customer].[Store Group].[Store Group] ON 1
FROM
(
SELECT
{[Calendar].[Month].[March 2015]} ON 0
FROM [F1_SalesBI]
);
输出如下:
Sales #
Store 1 156
Store 2 56
Store 3 546
...
Store 10 69
但我希望得到这样的报告:
March February January
Store 1 156 656 145
Store 2 56 89 41
Store 3 546 215 215
...
Store 10 69 69 96
对于我想要的输出,我应该如何查询?请帮助我!
以这种方式创建集合
WITH SET Last3Months AS
GENERATE
(
[Calendar].[Month].[March 2015],
{[Calendar].[Month].CURRENTMEMBER.LAG(2):[Calendar].[Month].CURRENTMEMBER}
)
这将创建一组最近 3 个月的数据集,包括当前月份(在数据集的定义中提供)
然后下面的查询将为您提供所需的信息。
SELECT
Last3Months ON 0
,NON EMPTY
[Customer].[Store Group].[Store Group].MEMBERS ON 1
FROM [F1_SalesBI]
WHERE {[Measures].[Sales #]}
Generate
看起来情况过于复杂了,也许只需要简单一点的东西:
SELECT
{
[Calendar].[Month].[March 2015],
[Calendar].[Month].[February 2015],
[Calendar].[Month].[January 2015],
} ON 0
,NON EMPTY
[Customer].[Store Group].[Store Group] ON 1
FROM [F1_SalesBI]
WHERE [Measures].[Sales #];
要使其动态化,使其只显示您多维数据集中的最后三个月,然后使用 Tail
函数,如下所示:
SELECT
Tail([Calendar].[Month].[Month].members,3) ON 0 //<< I've assumed this is ok but you may need to use [Calendar].[Month].members
,NON EMPTY
[Customer].[Store Group].[Store Group] ON 1
FROM [F1_SalesBI]
WHERE [Measures].[Sales #];
谢谢大家。这是我的 MDX 查询和这个 returns 2015 年 3 月生成的发票计数,非常有用!
WITH
SET [mySet] AS
[Customer].[Store Group].[Store Group] * {[Measures].[Sales #]}
MEMBER [Measures].[setDistCount] AS
DistinctCount([mySet])
SELECT
{
[Measures].[Sales #]
} ON 0
,NON EMPTY
[Customer].[Store Group].[Store Group] ON 1
FROM
(
SELECT
{[Calendar].[Month].[March 2015]} ON 0
FROM [F1_SalesBI]
);
输出如下:
Sales #
Store 1 156
Store 2 56
Store 3 546
...
Store 10 69
但我希望得到这样的报告:
March February January
Store 1 156 656 145
Store 2 56 89 41
Store 3 546 215 215
...
Store 10 69 69 96
对于我想要的输出,我应该如何查询?请帮助我!
以这种方式创建集合
WITH SET Last3Months AS
GENERATE
(
[Calendar].[Month].[March 2015],
{[Calendar].[Month].CURRENTMEMBER.LAG(2):[Calendar].[Month].CURRENTMEMBER}
)
这将创建一组最近 3 个月的数据集,包括当前月份(在数据集的定义中提供)
然后下面的查询将为您提供所需的信息。
SELECT
Last3Months ON 0
,NON EMPTY
[Customer].[Store Group].[Store Group].MEMBERS ON 1
FROM [F1_SalesBI]
WHERE {[Measures].[Sales #]}
Generate
看起来情况过于复杂了,也许只需要简单一点的东西:
SELECT
{
[Calendar].[Month].[March 2015],
[Calendar].[Month].[February 2015],
[Calendar].[Month].[January 2015],
} ON 0
,NON EMPTY
[Customer].[Store Group].[Store Group] ON 1
FROM [F1_SalesBI]
WHERE [Measures].[Sales #];
要使其动态化,使其只显示您多维数据集中的最后三个月,然后使用 Tail
函数,如下所示:
SELECT
Tail([Calendar].[Month].[Month].members,3) ON 0 //<< I've assumed this is ok but you may need to use [Calendar].[Month].members
,NON EMPTY
[Customer].[Store Group].[Store Group] ON 1
FROM [F1_SalesBI]
WHERE [Measures].[Sales #];