Duplicates in sub-report - crystal-reports

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;

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.

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

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, ",");

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.

how do i sum data pulled out of a sub-report in crystal

I am able to pull a field out of the sub report with
shared numbervar sub1Total;
but I need to add them up at the end of group. If I try and do a sum on the field in the main report I get an error that that field can not be used with sum.
You can add up the values passed back from the subreport by keeping track of them via a global variable in the main report.
//Initialize the variable in the Group Header of the main report
whileprintingrecords;
numbervar groupsub := 0;
//Update the variable in the Details section of the main report
whileprintingrecords;
numbervar groupsub;
shared numbervar subval;
groupsub := groupsub + subval;
//Print the accumulated group value in the Group Footer of the main report
whileprintingrecords;
numbervar groupsub;
Note: only works if the sum
groupsub := groupsub + subval;
is in Details Section

How do I create a Grand Total Summary based on a Group Summarized Formula In Crystal 10?

I have the following formula: #Sales_Cost
(Sum({Estimate_Retail_Inventory_Change___Detail.Sales_Ret_Final_Amount}, {Estimate_Retail_Inventory_Change___Detail.Inv ID}) -
(Sum ({Estimate_Retail_Inventory_Change___Detail.Sales_Ret_Final_Amount}, {Estimate_Retail_Inventory_Change___Detail.Inv ID}) *
{#GM%_For_Cost_Sales}))
This produces the following results and I have placed in my GH2 section:
592.77
1038.26
2628.38
3598.62
356.58
I want to total those values for my Report Footer, but I get the error message, "This field cannot be summarized".
How do I do this?
You need to create a manual running total. To do this you will create 3 new formula fields.
The first one goes in the report header to initialize the running total variable.
WhilePrintingRecords;
NumberVar manualTotal :=0;
The second one goes in the group header with your summary formula.
WhilePrintingRecords;
NumberVar manualTotal := manualTotal + {#Sales_Cost};
The third one goes in your report footer to display the calculated value.
WhilePrintingRecords;
NumberVar manualTotal;
manualTotal;;
Assuming {#GM%_For_Cost_Sales} will not vary within each Inv Id value (though it could vary across different values) and that the group for GH2 is on Inv Id, the simplest way to do this would be to change your formula item to:
{Estimate_Retail_Inventory_Change___Detail.Sales_Ret_Final_Amount} *
(1 - {#GM%_For_Cost_Sales})
- and place summed #Sales_Cost fields into both your GH2 group header and report footer sections.