按年份和月份排序

时间:2013-11-05 01:42:54

标签: reporting-services reportbuilder3.0

我正在使用Report Builder 3.0构建报告。我按月分组,但我的多维数据集中的月份字段的格式为" 2013年11月和#34;。它看起来不错,但它按字母顺序排序,而不是按日历顺序排序。

在搜索过程中,我找到了这个页面http://timyocum.blogspot.co.nz/2012/02/sorting-by-date-not-alphabetically-by.html

它有正确的想法,但它对我的数据格式不起作用。

任何人都可以帮我解决这个问题吗?

由于

大卫

1 个答案:

答案 0 :(得分:2)

按表达式排序:

=CDate(Fields!Month.Value)

这适用于您格式的数据,即使它是一个字符串。表达式将字符串转换为可以正确排序的日期,

我有一些基于字符串的示例数据:

select Month = '2013 October'
union all select Month = '2013 November'
union all select Month = '2013 December'

基于此的简单表:

enter image description here

[Month]排序:

enter image description here

=CDate(Fields!Month.Value)排序:

enter image description here

根据您添加的博客文章,您还可以轻松地将日期转换移至计算字段并按其排序,如果您在多个位置使用它,这可能很有用。