Replace formula
Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=20235
Printed Date: 18 May 2024 at 11:13pm
Topic: Replace formula
Posted By: natali
Subject: Replace formula
Date 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
|
Replies:
Posted By: lockwelle
Date 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
|
Posted By: natali
Date Posted: 19 Nov 2013 at 5:11am
Posted By: kostya1122
Date 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","")
|
Posted By: natali
Date Posted: 19 Nov 2013 at 7:15am
That is perfect. It works.
Thank you very much.
|
|