Wednesday, March 21, 2012

replace first few characters

how do i replace "Building" with bld ?

i will getting the data like this:

Buildling 100
Buildling 200
Buildling 300
Buildling 400
Buildling 500

i want like this:

Bld 100
Bld 200
Bld 300
Bld 400
Bld 500

in other words, where ever building replace with BLD

i'm using SRS 2000

thanks a lot

Hi,

You can do this either in the query or in the report.

In the query you can use the SQL REPLACE() function http://www.sqlteam.com/item.asp?ItemID=7386 if you are using a SQL data source. Or in the report you can use an expression like =Fields!MyValue.Value.ToString().Replace("Building", "Bld")

Thanks, Jon

|||

here is the error:

c:\Reporting.rdl The value expression for the textbox ‘txtBuilding’ refers to the field ‘bldg’. Report item expressions can only refer to fields within the current data set scope or, if inside an aggregate, the specified data set scope.

|||You either have an invalid reference (i.e. Fields!Bldg does not exist), or you are trying to reference the field outside of a proper scope (i.e. you have added it outside of a table/matrix/list without wrapping it in an aggregate function such as SUM() or FIRST())|||

=First(Fields!BLDG.Value.ToString().Replace("BUILDING", "BLD"), "db")

the above one works but it display all my 20,0000 records with the same building number and in fact i have different building numbers but it shows all building the same number

do you know why is not changing?

|||

myGreenBird wrote:


=First(Fields!BLDG.Value.ToString().Replace("BUILDING", "BLD"), "db")
...
do you know why is not changing?

Yes..

If you use =First(somecolumn,datasource) you will always get the first value that is returned from the Dataset..

What about

=Fields!BLDG.Value.ToString().Replace("BUILDING", "BLD") ?

You have to use this in a table or a list (beside your other columns), you cannot use it in page header or footer.

No comments:

Post a Comment