How to replace a dot with a space in SSRS? - reporting-services

I have a name field that in a report built in report builder. The name field sometimes shows a '..' or sometimes shows '. .'. I would like to Replace that using an expression in SSRS.
I've tried the expression below. But that didn't work:
=Fields!MyField.Value.ToString().Replace(". .", "")

The expression is you want is
=replace(Fields!MyField.Value.ToString(),".","")

I personally prefer to do this in SQL if possible.
REPLACE ( string_expression , string_pattern , string_replacement )

Related

Combining Remove and Replace Function in MS SQL Report Builder

A field gives me the following string:
#$TEXTA#$TEXTB#$TEXTC
I want to remove the #$-chars and seperate the values by a new line. In addition I want to replace special characters (&). In the end it should look like this:
TEXTA
TEXTB
TEXTC
So I use this code:
=Replace(Replace(Fields!My_Field.Value,"&","&"),"#$",Environment.NewLine)
The string starts with #$, so this code makes a new line in the beginning, which I want to avoid by using this code:
=Right(First(Fields!My_Field.Value, "DATASET"), Len(First(Fields!My_Field.Value, "DATASET"))-2)
I want to remove the first two chars before the replace function starts. My problem is, that I dont know how to combine these two functions to work properly.
Without testing this....
I think you should just be able to replace your reference to the field in your first expression, with your second expression, like this.
=Replace(
Replace(
Right(First(Fields!My_Field.Value, "DATASET"), Len(First(Fields!My_Field.Value, "DATASET"))-2)
,"&"
,"&"
),
"#$",
Environment.NewLine
)

I have some values in brackets I need to sum the values in ssrs

I HAVE VALUES LOOKS LIKE BELOW
1.(-250.00)
2. 1293.01
3. (-3567.78)
I NEED SUM OF these values using ssrs expression can anyone please helpme
I think the only way to get rid of the brackets is to REPLACE them and then use VAL to convert the resulting number into a number format. VAL doesn't seem to work on it's own like I thought it would.
=SUM(REPLACE(REPLACE(Fields!AMOUNT.Value, "(", ""), ")", ""))

Replace a part of a file path in a string field with SQL

Hello I have a table Gallery with a field url_immagine and I would like to use a query to replace all values that look like upload/gallery/311/ge_c1966615153f6b2fcf5d84c1e389eea8.jpg in /ge_c1966615153f6b2fcf5d84c1e389eea8.jpg
Unfortunately the a part of the string, the ID (331) is not always the same and therefore can not understand how ...
I tried the regular expression like this:
UPDATE gallery SET url_immagine = replace(url_immagine, 'upload/gallery/.*/', '/')
but it seem not to work.
Combine CONCAT and SUBSTRING_INDEX since you can use last index of "/"
UPDATE gallery
SET url_immagine = (SELECT CONCAT('/',SUBSTRING_INDEX(url_immagine, '/', -1)));
Try that to confirm it's doing what you want :
SELECT CONCAT('/',SUBSTRING_INDEX(url_immagine, '/', -1))
FROM gallery
You can see documentation for the replace function and all other string functions in the mysql manual:
https://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_replace
It does not mention that replace handles regular expressions, so we an assume it does not, and it is working verbatim and uses the your * to look for the char *.
You see also that there seem not to be a function that does the whole job for you. So you must somehow combine them. The idea of Mateo is probably the right direction.

how to write expression in SSIS variable to trim the file name after specific character

I have created a variable and writing an expression in SSIS variable to rename a file.
I have a file name like 'Filetodeploy_2014_05_01' I need to trim the characters after '_' (ie date) and display as 'Filetodeploy'
How can i build the above expression in a variable ?
thanks in advance
Try this
SUBSTRING( #[User::UDV_FileName] , 1, FINDSTRING( #[User::UDV_FileName] , "_",1 ) )
Also make it property true 'EvaluateAsExpression'

Expression issue in SSIS

I have a string like this format. In my case I need to extract only the characters from string case
1)12AB
2)SD12
3)1WE4
output
1)AB
2)SD
3)WE
I need to extract only the characters. I am using this expression in the derived column in SSIS package
SUBSTRING(MediaIDCode,1,2)
but this expression works for only this condition
1)12AB
I need to get an expression that works for all the conditions above. I have tried using REPLACE ( '' , '1', '') but it becomes a big expression.
The SUBSTRING function code you've posted will extract characters from a string without considering their content.
Have a look at using Regular Expressions to filter out unwanted characters:
http://consultingblogs.emc.com/jamiethomson/archive/2005/07/04/SSIS-Nugget_3A00_-The-script-component-and-regular-expressions.aspx
You could also use a synchronous script transformation to filter characters this way:
Dim NewMediaIDCode As String = ""
For Each c As Char In Row.MediaIDCode
If Not Char.IsDigit(c) Then
NewMediaIDCode += c
End If
Next
Row.MediaIDCode = NewMediaIDCode
I've used the IsDigit method here, but there's plenty of other methods to choose from.