Reporting services 报表服务-自定义格式
您好, 在其中一列中,我有如下值:Reporting services 报表服务-自定义格式,reporting-services,Reporting Services,您好, 在其中一列中,我有如下值: 9-7 9-18 9-142 9-142 9-18 9-7 目前,当我根据本栏进行排序时,我必须: 9-7 9-18 9-142 9-142 9-18 9-7 我想将这些值排序如下: 9-7 (so it would be 9-007) 9-18 (so it would be 9-018) 9-142 我尝试使用以下格式: =Format(Fields!ShelfNumber.Value,"000-000") 但它不起作用。有人能帮我吗?按以下表
9-7
9-18
9-142
9-142
9-18
9-7
目前,当我根据本栏进行排序时,我必须:
9-7
9-18
9-142
9-142
9-18
9-7
我想将这些值排序如下:
9-7 (so it would be 9-007)
9-18 (so it would be 9-018)
9-142
我尝试使用以下格式:
=Format(Fields!ShelfNumber.Value,"000-000")
但它不起作用。有人能帮我吗?按以下表达式排序:
=Cint(IIf(InStr(Fields!shelfnumber.Value,"-")<=1,"0",Left((Fields!shelfnumber.Value & "-"), InStr((Fields!shelfnumber.Value & "-"),"-")-1)))
=Cint(IIf(Fields!shelfnumber.Value="" or Len(Fields!shelfnumber.Value)=InStr(Fields!shelfnumber.Value,"-"),"0",Right(Fields!shelfnumber.Value, Len(Fields!shelfnumber.Value) - InStr(Fields!shelfnumber.Value,"-"))))
=Cint(IIf(InStr(Fields!shelfnumber.Value,“-”))对我的表应用此排序后,出现以下错误:表“table1”的排序表达式包含错误:参数“Length”必须大于或等于zero@niao-听起来好像有些货架编号中没有-
。除了格式为-
的字符串外,还可以使用哪些其他格式货架号是?也可以是空的string@niao:它不应该是完全空的值,因为答案中的代码考虑了这些值。可能是某些ShelfNumbers在字符串的开头或结尾都有-
-我现在编辑了答案,也考虑了这一点。@niao:进一步思考-是否存在任何空ShelfNumber?另外,您是从SQLServer数据库还是从其他形式的SQL进行报告?我建议您确定ShelfNumber字段的所有可能格式。如果它是完全自由格式的,您只需使用字符串排序(如现在一样)或不排序即可。