使用 SSAS 和 MDX 在列和行上显示不同的维度

发布于 2024-11-01 06:05:34 字数 482 浏览 3 评论 0原文

您好,我是 SSAS 和 MDX 的新手,我需要生成基于 OLAP 多维数据集的 ssrs 报告。 我不知道如何在列和行上显示不同的维度成员。 维度是列和客户上的评级和时间以及行上的状态,如下所示:

              | a rated | b rated  | c rated | Year-3 | Year-2 | Year-1 | Year* | Total|
good clients  |
medium clients|
bad clients   |
total clients |
status 1      |
status 2      |
status 3      |
total status  |
----------------------------------------------------------------------------------------

年份对应于当前年份。

如何使用 MDX 实现这一目标?

Hi I'm new to SSAS and MDX and I need to produce a ssrs report based on an OLAP cube.
I can't figure out how to display different dimension members on columns and rows.
The dimensions are rating and time on columns and clients and statuses on rows like this:

              | a rated | b rated  | c rated | Year-3 | Year-2 | Year-1 | Year* | Total|
good clients  |
medium clients|
bad clients   |
total clients |
status 1      |
status 2      |
status 3      |
total status  |
----------------------------------------------------------------------------------------

Year corresponds to the current year.

How can I achieve this with MDX?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

寂寞笑我太脆弱 2024-11-08 06:05:34

在 MDX 中,如果您想将不同维度的成员显示在同一轴上,可以将它们放入元组中。类似:

select  ([Time].[Calendar].[Year], [Rate].[rating].children) on columns,
select  ( ... , ... ) on rows
from [cube]

可能有助于解决您的问题。

in MDX you can put members of different dimensions into a tuple if you want to display them on the same axis. Something like:

select  ([Time].[Calendar].[Year], [Rate].[rating].children) on columns,
select  ( ... , ... ) on rows
from [cube]

may help solve your problem.

等你爱我 2024-11-08 06:05:34

MDX SELECT 语句的轴是一组具有相同“维度”的元组。这意味着所有元组必须包含相同维度的成员。因此,您不能按照您的要求拥有由不同维度的成员(成员是一个元组)组成的 MDX 集。

话虽这么说,我不明白:“收视率和时间栏是独立的”。这到底是什么意思?

An axis of an MDX SELECT statement is a set of tuples of same "dimensionality". That means that all tuples must contains the members of the same dimensions. So you cannot have an MDX set made of members (a member is a tuple) of different dimensions as you're requesting.

That being said, I do not understand: "the ratings and the time columns are independent". What does that mean exactly ?

行雁书 2024-11-08 06:05:34

一个 MDX 查询最多可支持 128 个指定轴,但很少有 MDX 查询会使用超过 5 个轴。对于前 5 个轴,可以使用别名 COLUMNS、ROWS、PAGES、SECTIONS 和 CHAPTERS。

尝试使用上述轴来实现您所期望的结果,例如查询两个不同的维度。

An MDX query can support up to 128 specified axes, but very few MDX queries will use more than 5 axes. For the first 5 axes, the aliases COLUMNS, ROWS, PAGES, SECTIONS, and CHAPTERS can instead be used.

Try to use the above axes to achieve what you are expecting like querying two different dimensions.

林空鹿饮溪 2024-11-08 06:05:34

下面的查询可能适合您。您提到您的多维数据集中没有“所有”成员,因此您需要将查询中的“所有”成员替换为相应的默认成员。我曾尝试在冒险作品中制作类似的情景。单元格有 internetSales 金额

               | topSeller | Bottom Seller  | 2011| 2012 | 
Topcustomers   |
Bottomcustomers|
North America  |
Europe         |

//create 
//SET [Adventure Works].[TopCustomers] AS TopCount(([Customer].[Customer].Members,[Sales Territory].[Sales Territory Country].[All]), 3,[Measures].[Internet Sales Amount])
//SET [Adventure Works].[BottomCustomers] AS bottomCount(([Customer].[Customer].Members,[Sales Territory].[Sales Territory Country].[All]), 3,[Measures].[Internet Sales Amount])
//SET [Adventure Works].[NorthAmerica] AS ([Customer].[Customer].[All],{[Sales Territory].[Sales Territory Country].&[United States],[Sales Territory].[Sales Territory Country].&[Canada]})
//SET [Adventure Works].[Europe] AS ([Customer].[Customer].[All],{[Sales Territory].[Sales Territory Country].&[France],[Sales Territory].[Sales Territory Country].&[Germany],[Sales Territory].[Sales Territory Country].&[United Kingdom]})
//
//SET [Adventure Works].[TopSellers] AS TopCount(([Product].[Model Name].Members,[Date].[Calendar Year].[All]), 3,[Measures].[Internet Sales Amount])
//SET [Adventure Works].[BottomSellers] AS BottomCount(([Product].[Model Name].Members,[Date].[Calendar Year].[All]), 3,[Measures].[Internet Sales Amount])
//SET [Adventure Works].[2011] AS ([Product].[Model Name].[All],[Date].[Calendar Year].&[2011])
//SET [Adventure Works].[2012] AS ([Product].[Model Name].[All],[Date].[Calendar Year].&[2012])
//

select 
{
([Measures].[Internet Sales Amount],[TopSellers]),
([Measures].[Internet Sales Amount],[BottomSellers]),
([Measures].[Internet Sales Amount],[2011]),
([Measures].[Internet Sales Amount],[2012])
}
on columns,

{
([TopCustomers]),
([BottomCustomers]),
([NorthAmerica]),
([Europe])
}
on rows
from [Adventure Works]

结果如下所示
结果

The query below might work for you. You mentioned you dont have "all" members in your cube, so you need to replace the "all" in the query with respective default members. I have tried to make a similar senario in Adventure works. The cells have internetSales amount

               | topSeller | Bottom Seller  | 2011| 2012 | 
Topcustomers   |
Bottomcustomers|
North America  |
Europe         |

//create 
//SET [Adventure Works].[TopCustomers] AS TopCount(([Customer].[Customer].Members,[Sales Territory].[Sales Territory Country].[All]), 3,[Measures].[Internet Sales Amount])
//SET [Adventure Works].[BottomCustomers] AS bottomCount(([Customer].[Customer].Members,[Sales Territory].[Sales Territory Country].[All]), 3,[Measures].[Internet Sales Amount])
//SET [Adventure Works].[NorthAmerica] AS ([Customer].[Customer].[All],{[Sales Territory].[Sales Territory Country].&[United States],[Sales Territory].[Sales Territory Country].&[Canada]})
//SET [Adventure Works].[Europe] AS ([Customer].[Customer].[All],{[Sales Territory].[Sales Territory Country].&[France],[Sales Territory].[Sales Territory Country].&[Germany],[Sales Territory].[Sales Territory Country].&[United Kingdom]})
//
//SET [Adventure Works].[TopSellers] AS TopCount(([Product].[Model Name].Members,[Date].[Calendar Year].[All]), 3,[Measures].[Internet Sales Amount])
//SET [Adventure Works].[BottomSellers] AS BottomCount(([Product].[Model Name].Members,[Date].[Calendar Year].[All]), 3,[Measures].[Internet Sales Amount])
//SET [Adventure Works].[2011] AS ([Product].[Model Name].[All],[Date].[Calendar Year].&[2011])
//SET [Adventure Works].[2012] AS ([Product].[Model Name].[All],[Date].[Calendar Year].&[2012])
//

select 
{
([Measures].[Internet Sales Amount],[TopSellers]),
([Measures].[Internet Sales Amount],[BottomSellers]),
([Measures].[Internet Sales Amount],[2011]),
([Measures].[Internet Sales Amount],[2012])
}
on columns,

{
([TopCustomers]),
([BottomCustomers]),
([NorthAmerica]),
([Europe])
}
on rows
from [Adventure Works]

The result looks like below
Result

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文