Controlling Sorting in SSRS Based Upon a Database Text Field

不问归期 提交于 2020-01-15 12:33:46

问题


I've been trying to find a way to even search for this without much luck.

Basically, I've got a text field in a table. All I'm trying to do is check if that text field contains a particular string, in this case, if this field contains either "OLD", "OBSOLETE", or "FOM" and then move it to the very bottom of the list, leaving everything else sorted normally. Is this possible? I'm trying to do this without hitting the SQL Statement itself too much if at all.


回答1:


You can do this by using a switch statement in the expression/function related to the sort. Logically a switch() is very similar to a case statement.

Under 'sorting options' add a new sort line item (or modify the existing item) by clicking the expression button to the right (Fx)

Then Modify the sort expression similar to this:

=Switch(Fields!YourField.Value="Old","xxx",
        Fields!YourField.Value="Obsolete","yyy",
        Fields!YourField.Value="Fom","zzz",
        1=1,Fields!YourField.Value)

This creates a switch statement that replaces the value to be sorted of the items you mentioned to xxx,yyy, & zzz effectively moving their sort value to the end of the list. Their displayed value will remain the same.

Switch stops evaluating when it finds the first true; so the final 1=1 is basically the otherwise clause that says sort by whatever the actual value of your field is when not old, obsolete, or fom.



来源:https://stackoverflow.com/questions/10541477/controlling-sorting-in-ssrs-based-upon-a-database-text-field

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!