Answered by:
How to get ordinal numbers from numeric

Question
-
Hi All,
I am getting new requirement of numeric value convert to ordinal number in ssrs report.
If have any global methods or classes as same in ax 2012 r3.Please let me know.
Example
1 - First
2 - Second
3 - Third
Thanks to all in advanced
Thursday, June 9, 2016 11:14 AM
Answers
-
Use Customer Code and call from the expression. Go to Report Tab>Report Properties>Code
Paste the below VB.NET code,
Public Function AddOrdinal(ByVal num As Integer) as String
Select Case (num Mod 100)
Case 11 To 13
Return num.ToString() & "th"
End Select
Select Case num Mod 10
Case 1
Return num.ToString() & "st"
Case 2
Return num.ToString() & "nd"
Case 3
Return num.ToString() & "rd"
Case Else
Return num.ToString() & "th"
End Select
End Function----------
You can use in the expression as,
=Code.AddOrdinal(Fields!id.Value)
Regards, RSingh
- Edited by Chongtham Rajen Singh Friday, June 10, 2016 3:58 AM
- Proposed as answer by Xi Jin Tuesday, June 28, 2016 9:05 AM
- Marked as answer by Simon_HouMicrosoft contingent staff Thursday, June 30, 2016 1:54 AM
Friday, June 10, 2016 3:57 AM -
Hi Gautam Reloaded,
According to your description, you want to convert numeric value to ordinal word. Right?
In your scenario, I would suggest you create a mapping table for numeric values and their corresponding ordinal words in dataset.
For more details, you can refer to Patrick Hurst’s method in following thread:
https://social.technet.microsoft.com/Forums/en-US/ea51477a-a690-4e77-8bfc-f5c8bf872951/numbering-format?forum=sqlreportingservicesIf you still have any questions, please feel free to ask.
Thanks,
Xi Jin.- Proposed as answer by Xi Jin Tuesday, June 28, 2016 9:05 AM
- Marked as answer by Simon_HouMicrosoft contingent staff Thursday, June 30, 2016 1:54 AM
Friday, June 10, 2016 7:17 AM
All replies
-
Use Customer Code and call from the expression. Go to Report Tab>Report Properties>Code
Paste the below VB.NET code,
Public Function AddOrdinal(ByVal num As Integer) as String
Select Case (num Mod 100)
Case 11 To 13
Return num.ToString() & "th"
End Select
Select Case num Mod 10
Case 1
Return num.ToString() & "st"
Case 2
Return num.ToString() & "nd"
Case 3
Return num.ToString() & "rd"
Case Else
Return num.ToString() & "th"
End Select
End Function----------
You can use in the expression as,
=Code.AddOrdinal(Fields!id.Value)
Regards, RSingh
- Edited by Chongtham Rajen Singh Friday, June 10, 2016 3:58 AM
- Proposed as answer by Xi Jin Tuesday, June 28, 2016 9:05 AM
- Marked as answer by Simon_HouMicrosoft contingent staff Thursday, June 30, 2016 1:54 AM
Friday, June 10, 2016 3:57 AM -
Hi Gautam Reloaded,
According to your description, you want to convert numeric value to ordinal word. Right?
In your scenario, I would suggest you create a mapping table for numeric values and their corresponding ordinal words in dataset.
For more details, you can refer to Patrick Hurst’s method in following thread:
https://social.technet.microsoft.com/Forums/en-US/ea51477a-a690-4e77-8bfc-f5c8bf872951/numbering-format?forum=sqlreportingservicesIf you still have any questions, please feel free to ask.
Thanks,
Xi Jin.- Proposed as answer by Xi Jin Tuesday, June 28, 2016 9:05 AM
- Marked as answer by Simon_HouMicrosoft contingent staff Thursday, June 30, 2016 1:54 AM
Friday, June 10, 2016 7:17 AM