0
votes

I am making a custom sum formula in my Crystal Report. The key is to sum records when another cell has a specific value. For example... I have 2 rows with 3 records for each. If the value in the first row is 1 in two records, I want to sum those 2 records in the other row. You can find my example which is not working. Regards.

if {sp_rptInternal;1.Tax_Rate_Percentage}=10.00
then 
Sum ({sp_rptInternal;1.Sell_Price})

UPDATE 1: Values(bold) from the red rectangle needed to be placed inside my custom table below. UPDATE 2: I tried grouping with Image 2 and 3, but it is not working.

Image 1.

enter image description here

Image 2.

enter image description here

Image 3.

enter image description here

3
Can you post the table and then explain. It is difficult to understand like this.JulyOrdinary
Here it is. @ItiTyagiFerid Š. Sejdović
You description says value is "1", and your code shows "10". Also, if value in column is 1.00 then only you need to sum? Right? Basically, sum rows which have tax precentage of 1.00?JulyOrdinary
I added two more pictures. I need grouped sum value in the table below(Image 1). @ItiTyagiFerid Š. Sejdović
I would suggesst, you to bring the grouped value from code-behind, as seems like you need to place these values outside groups section.JulyOrdinary

3 Answers

1
votes

In the detail section, use something like:

if {sp_rptInternal;1.Tax_Rate_Percentage}=10.00 then {sp_rptInternal;1.Sell_Price} ELSE 0

In the group footer or header, show a sum of that formula.

1
votes

It sounds like you'll need to use a running total. You can group the data, insert a sum type running total on the detail line and use a custom formula for the sum condition like: {record1}=previous({record1}).

Sometimes the running total function in Crystal doesn't work exactly as expected at the very beginning or end of the report so check that thoroughly under varying conditions. If it's not quite right you may need add extra conditions to your formula or create manual running totals (which is usually the method I go for because you have more control).

0
votes

The only possible way is to make shared/global variables which can be used anywhere, in every section of the report, dynamically. Source can be provided from code-behind or via formula.