按年和月名排序 [英] Sorting by year and monthname
问题描述
我正在使用 Report Builder 3.0 构建报告.我按月份分组,但我的多维数据集中的月份字段的格式为2013 年 11 月".看起来不错,但它是按字母顺序而不是日历顺序排序的.
I am building a report using Report Builder 3.0. I am grouping by Month, but the Month field in my cube is in the format "2013 November". It looks good, but it sorts alphabetically instead of in calendar order.
在我的搜索过程中,我找到了这个页面 http://timyocum.blogspot.co.nz/2012/02/sorting-by-date-not-alphabetically-by.html
During my searching I found this page http://timyocum.blogspot.co.nz/2012/02/sorting-by-date-not-alphabetically-by.html
它有正确的想法,但它不适用于我的数据格式.
It has the right idea, but it doesn't work for the format of my data.
谁能帮我解决这个问题?
Can anyone help me figure this out?
谢谢
大卫
推荐答案
按表达式排序:
=CDate(Fields!Month.Value)
这适用于您的格式的数据,即使它是一个字符串.表达式将字符串转换为可以正确排序的日期,
This works OK for data in your format, even if it's a string. The expression converts the string to a date which can be sorted correctly,
我有一些基于字符串的示例数据:
I have some sample string-based data:
select Month = '2013 October'
union all select Month = '2013 November'
union all select Month = '2013 December'
基于此的简单表格:
按[月份]
排序:
按=CDate(Fields!Month.Value)
排序:
根据您所包含的博文,您还可以轻松地将日期转换移动到计算字段并按其排序,如果您在多个地方使用它,这可能会很有用.
As per the blog post you include, you could also easily move the date conversion to a calculated field and sort by that, which could be useful if you're using it in multiple places.
这篇关于按年和月名排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!