Forum Discussion
Rpt Builder-extracting partial text from large text field until a period is found
- Anonymous1 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.
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.
- ldwf1 year ago
Helper V
Thanks for the response. Unfortunately, it doesn't work , although I do not get any error messages. I will provide you more details now.. The data does reside in SQL server. The screenshot shows you how it looks when I query it in SQL server where you can see the html characters. While I don't get any error messages, the first of the four fields defined always returns a value of 0. Maybe this is because of the html? Since this field isn't correct, the other fields won't be either. Here is a screenshot of the data in SQL server. :
- ldwf1 year ago
Helper V
I did get this to work following your instructions, and will therefore accept it as the solution. Thank you