Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Replace formula Post Reply Post New Topic
Author Message
natali
Newbie
Newbie
Avatar

Joined: 15 Jan 2013
Online Status: Offline
Posts: 26
Quote natali Replybullet Topic: Replace formula
    Posted: 19 Nov 2013 at 4:20am
Could someone help me with Replace formula.
How can I replace two different words in the same field?
For example:
Admin Salaries 
Admin Benefits
Marketing Salarie
Marketing Benefit
 
I need to remove words SALARIES and BENEFITS but keep the rest of the description.

Thank you in advance.

Natalie
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 19 Nov 2013 at 5:10am
local stringvar y :={table.field};
local numbervar x :=instr(y, "Salaries");
if x > 0 then
y:=left(y, 1, x-1) + mid(y, x + len("Salaries"));

x := instr(y, "Benefits");
if x > 0 then
y:=left(y, 1, x-1) + mid(y, x + len("Benefits"));

y


this should work. It won't adjust for capitalization...though that should be easy to add in.

HTH
IP IP Logged
natali
Newbie
Newbie
Avatar

Joined: 15 Jan 2013
Online Status: Offline
Posts: 26
Quote natali Replybullet Posted: 19 Nov 2013 at 5:11am

Thank you. I will try

IP IP Logged
kostya1122
Senior Member
Senior Member
Avatar

Joined: 13 Jun 2011
Online Status: Offline
Posts: 475
Quote kostya1122 Replybullet Posted: 19 Nov 2013 at 7:08am
you could also try

if {table.field} like"*Salaries*"
then replace({table.field},"Salaries","") else
if {table.field} like"*Benefit*"
then replace({table.field},"Benefit","")
IP IP Logged
natali
Newbie
Newbie
Avatar

Joined: 15 Jan 2013
Online Status: Offline
Posts: 26
Quote natali Replybullet Posted: 19 Nov 2013 at 7:15am
That is perfect. It works.
Thank you very much.Thumbs%20Up
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.