Skip to Content
author's profile photo Former Member
Former Member

split the value using comma as delimiter and then pass each value to query to get the description


As i am new to crystal reports, I need help in getting one field.

In my report i am using 2 tables:

one is like :

code_id code_desc 1 aaa 2 bbb 3 ccc 4 ddd

and the another is :

reason_ind 1 2,3,4 2,3 1,2,3,4 3,4

In this report i have a column : Reason_desc.

Here i have to show code_desc for those values of reason_ind matches with code_id in the above table.


reason_ind reason_desc 1 aaa 2,3,4 bbb,ccc,ddd 2,3 bbb,ccc

Let me know if you need further clarifications.

Thanks in advance.



Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Jul 21, 2014 at 09:03 AM

    Hi Swathi,

    Here's how you can do this at the report level:

    1) Create a Main report pointing to the second table from that screenshot.

    2) Drag and drop the Reason_ind column on the Details Section

    3) Insert a Subreport pointing to the First table and place it on the Details Section

    4) Right-click the Subreport > Select Change Subreport Links > Move the Reason_Ind field to the pane on the right > Uncheck the option 'Select data in Subreport based on field'

    5) Get inside the Subreport and go to Report > Selection Formulas > Record and use this code:

    ToText({Code_Id},0,"") IN Split({@Pm-Reason_Ind},",")

    6) In the Subreport, create a Group on the Code_Desc field

    7) Suppress the Report Header, Group Header, Details and Group Footer sections

    8) Create a Formula with this code and place it on the Group Header 1 section:


    stringvar s := s + {Code_Desc} + ", ";

    9) Create one more formula and place this on the Report Footer section:


    stringvar s;


    Hope this helps.


    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.