我已经在报告中编写了以下TSQL:
SELECT patcnty, CASE WHEN CAST(age_yrs AS int) <= '5' THEN 'Ages 5 and Younger' WHEN CAST(age_yrs AS int) BETWEEN '6' AND
'17' THEN 'Ages 6 to 17' WHEN CAST(age_yrs AS int) BETWEEN '18' AND '44' THEN 'Ages 18 to 44' WHEN CAST(age_yrs AS int) BETWEEN '45' AND
'64' THEN 'Ages 45 to 64' WHEN CAST(age_yrs AS int) >= '65' THEN 'Ages 65 and Older' END AS AgeGroup,
CASE WHEN patcnty = '54' THEN 'Tulare' WHEN patcnty = '16' THEN 'Kings' WHEN patcnty = '15' THEN 'Kern' WHEN patcnty = '10' THEN 'Fresno' END
AS County, oshpd_id, age_yrs
FROM OSHPD2009
WHERE (patcnty IN ('10', '15', '16', '54')) AND (age_yrs <> ' ')
我创建了一份SSRS 2005 Matrix报告,并将AgeGroup作为我的列,将County作为我的行。显示报告时,列的顺序为:年龄18至44岁,年龄45至64岁,年龄5岁和年轻人,年龄6至17岁以及年龄65岁及以上。这是有道理的,因为我将组的排序顺序设置为升序。
如何更改矩阵列的组排序顺序以这种方式排序: 年龄5岁和年轻人,年龄6至17岁,年龄18至44岁,年龄45至64岁以及65岁及以上年龄?
非常感谢你的帮助!
答案 0 :(得分:3)
经过一番挖掘,我决定需要告诉SSRS按什么顺序排序。因此,在列分组排序屏幕中,我添加了
的表达式=iif(Fields!AgeGroup.Value="Ages 5 and Younger","1",
iif(Fields!AgeGroup.Value="Ages 6 to 17","2",
iif(Fields!AgeGroup.Value="Ages 18 to 44","3",
iif(Fields!AgeGroup.Value="Ages 45 to 64","4",
iif(Fields!AgeGroup.Value="Ages 65 and Older","5","Other")))))
这基本上迫使SSRS按照我指定的顺序对组进行排序,方法是将Ages 5和Younger分配为1,这样它就是第一个排序组等。我的报告现在就像一个魅力!
答案 1 :(得分:2)
或者您可以修改源表以包含AGe_Group订单的新列。在SSRS上,您可以根据新的列顺序进行排序。澄清:
Newcolumn int
Set NewColumn = 1
where AgeGroup = "Ages 5 and Younger"
Set NewColumn = 2
where AgeGroup = ="Ages 6 to 17"
Set NewColumn = 3
where AgeGroup = Ages 18 to 44"