BOB: Business Objects Board
Not endorsed by or affiliated with SAP

Register | Login 

Follow BOB on Twitter! 
Follow BOB on Twitter! (Opens a new window)  

General Notice: Upcoming Events: BOBJ conference in Paris: Mar 28, PGHBOUG: Apr 4.

convert text to number value and keep text as text


 
Search this topic... | Search Crystal Reports... | Search Box
Register or Login to Post    Forum Index -> Building Reports -> Crystal Reports  Previous TopicPrint TopicNext Topic
Author Message
whitecastle
Forum Member
Forum Member



Joined: 12 Mar 2019

Posts: 3



PostPosted: Tue Mar 12, 2019 8:33 am 
Post subject: convert text to number value and keep text as text

I have a string of data that is numbers and text that all exports as text, but I want the numbers to say as number values and text to stay as text.

I tried this, but it doesn't work.

If Not isNull({ord_ln.ordnum}) Then
If isNumeric({ord_ln.ordnum}) Then
ToNumber({ord_ln.ordnum})
Else {ord_ln.ordnum}
Back to top
kevlray
Forum Associate
Forum Associate



Joined: 23 Jun 2010

Posts: 935
Location: California


flag
PostPosted: Tue Mar 12, 2019 9:10 am 
Post subject: Re: convert text to number value and keep text as text

You did not say what you were exporting to. I am assuming Excel. Also what tool are you using to export (Deski, Webi, Crystal Reports)?
Back to top
whitecastle
Forum Member
Forum Member



Joined: 12 Mar 2019

Posts: 3



PostPosted: Tue Mar 12, 2019 9:12 am 
Post subject: Re: convert text to number value and keep text as text

Sorry I'm exporting from Crystal Reports to excel. But I'm needing the logic written inside Crystal reports so when i export it to excel it is already formatted the way I need it.
Back to top
Marek Chladny
Forum Advocate
Forum Advocate



Joined: 27 Nov 2003

Posts: 19250
Location: Bratislava


flag
PostPosted: Tue Mar 12, 2019 9:23 am 
Post subject: Re: convert text to number value and keep text as text

[Moderator Note: Moved from General Discussion to Crystal Reports]
Back to top
kevlray
Forum Associate
Forum Associate



Joined: 23 Jun 2010

Posts: 935
Location: California


flag
PostPosted: Tue Mar 12, 2019 2:50 pm 
Post subject: Re: convert text to number value and keep text as text

Unfortunately when exporting to Excel. Excel looks at the first few values and determines what it thinks the data type is. I have yet to figure out how Excel does this. Maybe someone else knows.
Back to top
whitecastle
Forum Member
Forum Member



Joined: 12 Mar 2019

Posts: 3



PostPosted: Tue Mar 12, 2019 7:47 pm 
Post subject: Re: convert text to number value and keep text as text

My issues is within Crystal Reprots not excel. I'm trying to write the code within Crystal Reports so when my report runs it converts a string data that is a number to values and text stays the same. It can get half of it I just can't figure out the 2nd half.

for example:

Ord Number
123
C5654

I want the 123 to be converted a value and I want C5654 to stay as a text.

If Not isNull({ordnum}) Then
If isNumeric({ordnum}) Then
ToNumber({ordnum})
Else 0

The above converts the numbers to a value correctly, but it changes the C Ord numbers to 0 instead of keeping the original.

I tried using this instead, but it doesn't like the last line it says it needs a value instead.

If Not isNull({YourStringField}) Then
If isNumeric({YourStringField}) Then
ToNumber({YourStringField})
Else {ordnum}
Back to top
kevlray
Forum Associate
Forum Associate



Joined: 23 Jun 2010

Posts: 935
Location: California


flag
PostPosted: Wed Mar 13, 2019 9:11 am 
Post subject: Re: convert text to number value and keep text as text

The problem then is that you can have only one data type per field (expression). So you can either have the expression return a number or a string (of course other data types are available, but not relevant in this situation).
Back to top
Display posts from previous:   
Register or Login to Post    Forum Index -> Building Reports -> Crystal Reports  Previous TopicPrint TopicNext Topic
Page 1 of 1 All times are GMT - 5 Hours
 
Jump to:  

Index | About | FAQ | RAG | Privacy | Search |  Register |  Login 

Get community updates via Twitter:

Not endorsed by or affiliated with SAP
Powered by phpBB © phpBB Group
Generated in 0.0330 seconds using 17 queries. (SQL 0.0031 Parse 0.0014 Other 0.0285)
CCBot/2.0 (https://commoncrawl.org/faq/)
Hosted by ForumTopics.com | Terms of Service
phpBB Customizations by the phpBBDoctor.com
Shameless plug for MomentsOfLight.com Moments of Light Logo