Crystal Reports - concatenating rows based on a field's value - crystal-reports

I have a report by a dataset by two master-detail tables (For example, Organizations and Persons).
I have a group section by the master ID.
I want to show the list of the persons in each organization separated by comma in a single row instead of showing each person in a row.
How can I do it?

I found out how can I do it.
I added a group on organizationID.
Added this formula to the group's header section and suppressed it:
WhilePrintingRecords;
StringVar Array reset;
StringVar Array names:=reset;
True;
Added this formula to the detail section and suppressed it:
WhilePrintingRecords;
StringVar Array names;
Redim Preserve names[Ubound(names)+1];
names[Ubound(names)]:={persons.name_field};
Added this formula to the group's footer section:
//{#display}
WhilePrintingRecords;
StringVar Array names;
Join(names, ",");

Related

Crystal Report Shared NumberVar from sub-report to main-report. Why first record display 0 value?

I need to get Shared NumberVar from Sub-Report to Main-Report but first record display 0 value in this Group footer (My value display on Group footer) value do not match in same line
I need to display correct value in same line.
Please help.
Sub-Report
WhilePrintingRecords;
Shared NumberVar qty;
qty:= sum({OE.QTYSOLD});
Main-Report
WhilePrintingRecords;
Shared NumberVar qty;
Main report formula getting a subreport shared variable value must be in a section BELOW the subreport section. This is because section formulas are evaluated before subreports in the same section.
So split the section or move the subreport to a higher section.

Duplicates in sub-report

I have crystal report with a sub report in it. The sub report is displaying duplicates. To avoid that I used below formula.
{table.IDField} = previous({table.IDField})
Now, duplicates are removed but I have sum of the field in the footer. All the duplicate values are added to the sum. Is there a way that I can select distinct records in the sub report?
I followed below steps to solve this issue.
Created a group on the IDField
Moved all the fields from detail section to the above group header.
Suppressed the detail section.
Created the below formula and placed it in group header. I have supressed this because I didn't have to display this.
whileprintingrecords;
numbervar totalOfIDField := totalOfIDField + {IDField};
"";
Created a formula to display the above field (totalOfIDField).
whileprintingrecords;
numbervar taotalOfIDField;
This should be placed in the corresponding Group Footer.
Created a formula to reset the totalOfIDField each time group changes. Included this in the Main Group Header.
whileprintingrecords;
numbervar totalOfIDField := 0;

Crystal Report: Summarize multiple date fields in one

please help me..I've been trying to search this for weeks but can't find the answer..
Given: Currently I have these dates field on my crystal.
01/01/2015
02/24/2015
02/27/2015
02/28/2015
02/29/2015
How can I summarize it in one field to be like this,
01/01/2015, 02/24/2015, 02/27-2015 - 02-29-2015
generally, separate different dates with comma and join dates that are in range or consecutive in order.
Thank you very much.
There is no direct way of summarizing the field in crystal report like you mentioned in your question.
However, you could try a work-around.
Create a Group and group by the 'date' field you want to summarize and then-
1) Create a formula with a shared variable to be placed in the header section of the report:
shared stringVar result="";
2) Create another formula with the same shared variable to be placed in detail section which concatenates your result into a comma separated array:
whileprintingrecords;
shared stringVar result;
if(result='')
then result:=CStr ({Date1.Date1_Text})
else
result:=result + "," +CStr ({Date1.Date1_Text});
Here ,{Date1.Date1_Text} is the date field which you want to summarize.
3) Create another formula with the same shared variable to be placed at the report footer:
shared stringVar result;
NumberVar i;
StringVar array dates := Split(result,",");
//Here you could put your logic to convert dates to date range.
//....
result; // returns final result

Summarizing a group header formula field in the footer in Crystal Xi

I am trying to put the summarization of a formula that is in the header in the footer. The body of the report is hidden as only the summaries are relevant.
The formula in the header is
{#orig_balance}+{rtetable.transactioncalculatedprice}.
I only want the first record of the set(which is why I have it in the header). Now I want to summarize these records and have them show in the footer.
I have two headers...the first is accounts and the second is primary ID. I have this formula in the primary id and want it summarized in the accounts.
I have been banging my head against the wall now and need some help....Please
Assuming you have two groups and hence two headers.
In group hear1 write below formula #Reset and place to left most part.
Shared Numbervar Store;
Store:=0;
In group header1 write below formula Store and place to the right of Reset:
Shared Numbervar Store;
Store:=<<Group header1 value>>;
In group header 2 Calculate write belwo formula:
Shared Numbervar Store;
Store:=Store+<<group header2 value>>;
In group footer display write below formula:
Shared Numbervar Store;
Store;
Let me know if this is not your requirement.

crystal subreport field is blank in main report footer

I have a subreport that has one group and has the following formula in Group Header 1
WhilePrintingRecords;
Shared StringVar TaskSubject := {activity_trans.subject}
My main report has the following formula in Group Footer 1
WhilePrintingRecords;
Shared StringVar TaskSubject;
TaskSubject
When I drill into the detail section of my main report the field shows a value in the GF1 section but when I preview the main report the field is blank.
The problem with putting the formula in the Group Header is that you only get one record for the formula, which usually is the first record available. If that first record is blank, then you will see no data. Your formula is correct, but there may be an issue with the way you have structured your report or the data you are trying to display.