SSRS Extract substring from string before the second string

a415 picture a415 · Dec 1, 2016 · Viewed 20.9k times · Source

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?

Answer

alejandro zuleta picture alejandro zuleta · Dec 1, 2016

In SSRS you can use LEFT and InStrRev functions:

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

Let me know if this helps.