Forum Discussion

ldwf's avatar
ldwf
Icon for Helper V rankHelper V
1 year ago
Solved

Rpt Builder-extracting partial text from large text field until a period is found

In SSR/SReport Builder, I need to search a large text field for a specific value, and return that value and return everything to the right of that value until a period is found. For example, I have a...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi, ldwf 

    I am glad to help you.

     

    Since you didn't give me some data to test, I assumed a simple dataset in SQL Server myself:

     

    Connect to SQL Server using Microsoft Report Builder and select the corresponding database and the corresponding table:

     

     

     

    You can create four Calculated Fields to realize the requirements in steps:

     

     

    StartPosition:

    =InStr(Fields!Description.Value, "Business Requirement IDs:")

     

    SubStringFromStart:

    =Mid(Fields!Description.Value, Fields!StartPosition.Value)

     

    FirstPeriodPosition:

    =InStr(Fields!SubStringFromStart.Value, ".")

     

    FinalExtractedText:

    =Mid(Fields!Description.Value, Fields!StartPosition.Value, Fields!FirstPeriodPosition.Value)

     

    Drag the Calculated Fields to the Table/Matrix and click Run:

    Output:

     

     

     

    Of course you can also create only one Calculated Field directly to fulfill the requirement:

    Description1:

    =Mid(Fields!Description.Value, InStr(Fields!Description.Value, "Business Requirement IDs:"), InStr(Mid(Fields!Description.Value, InStr(Fields!Description.Value, "Business Requirement IDs:")), "."))

    Drag the Calculated Field to the Table/Matrix and click Run:

    Output:

     

     

     

    I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
    Best Regards,
    Fen Ling,
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.