Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSRS Extract substring from string before the second string

I have a field which is like the following 4444-4444-TestingItem1. Is it possible for me to extract the field up until 4444-4444. if so how would I do this? What function would I use within SSRS. Please note It could be any number of characters before the first dash and before the second dash.

How can this be achieved within SSRS?

like image 600
a415 Avatar asked Dec 01 '16 01:12

a415


People also ask

How do I find substring in SSRS?

You can use functions like MID(), LEFT(), RIGHT(), LEN(), INSTR() to get a part of string.

What is first function SSRS?

The First function returns the first value in a set of data after all sorting and filtering have been applied at the specified scope. The First function cannot be used in group filter expressions with anything except the current (default) scope.

What is Instr in SSRS?

instr = The instr function returns the position of the first occurrence of one string within another. This position is based on a 1 based index of the characters in the string.


1 Answers

In SSRS you can use LEFT and InStrRev functions:

=LEFT(Fields!YourField.Value,InStrRev(Fields!YourField.Value,"-")-1)

Let me know if this helps.

like image 80
alejandro zuleta Avatar answered Sep 27 '22 22:09

alejandro zuleta