Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Truncate formula

Posted on 2010-09-20
8
Medium Priority
?
699 Views
Last Modified: 2012-05-10
Hi Experts,

I need to show only the NUMERIAL value of my string. For instance, I need to show only the NUMERICAL values from the following customer name string:

Carpet Court Kogaraha SN25251
Carpet Court Dubbo SN25981
Carpet Court Design SN 22598

Intened result:
25251
25981
22598


NOTE: The numerical value in the customer name string has maximum of 5 characters. In some occassion, there is a SPACE between SN and the Numerical value (e.g., SN 22560). I wan to capture only the NUMERICAL value.

I'm using the below formula but it is giving me a DECIMAL place before the result.
Val(strreverse(Cstr(val(StrReverse ({Sheet1_.Sold-to party} )),5,'')))

Result:
.25251
.25981
.22598

How do I remove the DECIMAL infront as shown above.

Heaps of thanks
0
Comment
Question by:mcse2007
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 8

Accepted Solution

by:
kingjely earned 800 total points
ID: 33722321

Hi There
You can remove all '.''s in your field like this

UPDATE Yourtable SET YourField = replace(YourField, '.','');

Regards,
Kj
0
 
LVL 5

Assisted Solution

by:Priya Perumpilavil
Priya Perumpilavil earned 200 total points
ID: 33722322
try this
Right ({Sheet1_.Sold-to party}, 5)
0
 
LVL 8

Expert Comment

by:kingjely
ID: 33722325
Aw, sorry mine was if you wanted to update the data, in your database

EG in SQL so you didn't have them in the field at all.. may still help you.. Not sure.





0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 7

Author Comment

by:mcse2007
ID: 33722346
kingjely:
Just cannot remember in the past how it worked for me...i must have formated the result using the FORMAT FIELD.

PriyaPadman:
i've already tried that but the problem with that is as mentioned above there are customers name where their SN has a gap then the NUMERICAL VALUE value (e.g., SN 2256). I don't want any space just pure Numerical value.
0
 
LVL 7

Author Comment

by:mcse2007
ID: 33722374
Ok, i've used my old formula and it worked fine..here it is. sorry for posted this.

stringvar str;
str :=trim(Replace({table.field},"SN ", "SN"));
str := mid(str, instrrev(str," ")+3);
val(str)
0
 
LVL 5

Expert Comment

by:Priya Perumpilavil
ID: 33722377
so y dont u put val infront of the formula as
val(Right ({Sheet1_.Sold-to party}, 5))
0
 
LVL 8

Expert Comment

by:kingjely
ID: 33722378
same as my update, SET in SQL, but in crystals ;)

glad you got it !
0
 
LVL 35

Expert Comment

by:James0628
ID: 33732321
FWIW, the problem with the formula in your original post was the format options you used for CStr.  If you break that formula down and remove the Val and StrReverse that were around the CStr, you'll see that you get results like "15252.00000".  That's because you told CStr to use 5 decimal places and no thousands separator.  So "25251" is reversed to "15252", which Val converts to 15252 (a number), which CStr converts to "15252.00000" (a string).  When you reverse that and convert it to a number, you get 0.25251, which you were showing as .25251.

 If you use the "#" format with CStr, as shown below, that formula works.  The "#" format says to not show any thousands separator or decimal places, so the number 15252 is converted to the string "15252" (instead of "15252.00000"), which reverses to "25251", which converts to the number 25251.

Val(strreverse(Cstr(val(StrReverse ("Carpet Court Kogaraha SN25251")),"#")))


 I don't need any points for this.  I just wanted to let you know why the first formula didn't work.

 James
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question