开发者

Reporting services - custom format

Greetings, inside one of the column I have values like the following:

9-7
9-18
9-142

At the moment, when I sort based on this column I have to following:

9-142
9-18开发者_C百科
9-7

I would like to sort these values to be ordered as follows:

9-7 (so it would be 9-007)
9-18 (so it would be 9-018)
9-142

I tried to following format:

=Format(Fields!ShelfNumber.Value,"000-000")

But it doesn't work. Can someone help me, please?


Sort on the following expressions:

=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,"-"))))

The first converts the characters before the - to a number, the second converts the characters after the - to a number.

EDITED, to allow for an empty string.

FURTHER EDITED, to allow for ShelfNumbers with - at the start or end of the string.

FURTHER EDITED, following testing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜