Question originally posted in Spanish, on es.stackoverflow.com, by Sebastián Miranda:
I am working with Crystal Report since Visual Studio 2017, I was asked
to make a sum to group, I have 3 options: Credit Notes, Ballot and
Invoice.
The first thing I did was to create a Formula Field with the name
NumberValorCif to convert the ICIF Value that I have to numeric with ToNumber (). I saved this and created another formula field
named SumCIFCredito that has the following code:
If {CobroPorcentaje.TipoDoc} = 'Credit Notes'
then {#NumberValorCif}
else 0
I saved, compiled and ran the application and it worked without any
problems ... but. I wanted to do the same for SumCIFBoleta:
If {CobroPorcentaje.TipoDoc} = 'Ballot'
then {#NumberValorCif}
else 0
But I don't add anything. I'm missing something? or I have to create
another variable.
I hope someone can help me.
Thank you so much
It sounds like you simply need to add the actual SUM of that new formula.
Place the new formula in the detail section, select it, hit the Sigma button to sum it, and elect to generate subtotals for your Grouping level.
Related
I currently have a Crystal Report with a selection formula that looks like this
{dbo.CustomerName}={?CustomerName}
AND
{dbo.Opportunity}={?Opportunity}
An issue that I'm finding is that sometimes there isn't a matching customer name, but the report still needs ran on the subsequent selection formula. Is there a way to create an IF THEN statement that says something like:
IF IsNull({dbo.CustomerName}={?CustomerName})
THEN
{dbo.Opportunity}={?Opportunity}
ELSE
({dbo.CustomerName}={?CustomerName} AND {dbo.Opportunity}={?Opportunity})
Obviously the IsNull operator requires a field and not a statement, but I'm not sure how to accomplish what I'm trying to accomplish
The following should work:
(IsNull({dbo.CustomerName}) AND {dbo.Opportunity}={?Opportunity})
OR
({dbo.CustomerName}={?CustomerName} AND {dbo.Opportunity}={?Opportunity})
I can't find any help online with my problem maybe due to that I don't know the exact keywords to use but hear me out.
Here is the screen shot of my report format...
The actual report result appears like this...
The next item appears beside (right side) the first result. I want it to appear below instead like this...
How do I achieve this? Just comment any additional information that is needed.
BTW, I am using visual studio 2013 (Seems like it matters).
UPDATE:
This is the report format that I want to copy. The headers are not important just the body of the report. Thanks!
Try to use grouping go to this link hope this gives you a clue thanks
Finally found out what's wrong. I removed the column groupings and added only a parent row group. Then I added all needed rows and columns inside the group. It was fairly easy once I found out the problem.
Here's the output of my report.
Thanks guys!
How can I achieve this? I also tried using "print when expression" with condition
new Boolean($V{PAGE_NUMBER}.intValue() < $V{PAGE_COUNT}.intValue())
but sadly it does not work. Please help me.
This print when expression works fine for me $V{PAGE_NUMBER}<$V{PAGE_COUNT}. It works when applied to either the column footer band or the footer band element (I used static text).
Comparing PAGE_NUMBER and PAGE_COUNT is like comparing apples and oranges.
The Built-In Variables
PAGE_NUMBER: At every iteration it contains the number of the pages that compose the report.
PAGE_COUNT: Contains the number of record processed in the current page
To answer the question: JasperReports knows a band type "Last Page Footer" (wiki description) to define a different footer on the last page.
(Your problem might already be solved. But I stumbled upon this two year old question while having a similar issue and wanted to leave a hint, that one should not compare those variables.)
I'm having problem with JasperReports report by getting sum of two fields.
I have created so far variables that holds fields "TareWeight" variable that is casting values from double to float
new Float($F{EquipmentTareWeightKg})
"CargoWt" variable that is casting from string to float, etc...
Float.parseFloat($F{UfvFlexString03})+Float.parseFloat($F{UfvFlexString04})
So now I have two variables which I can manipulate with.
The problem starts when I wish to do a "recap" using crosstab. I have setup two groups that is done with wizard, and added another in crosstab. (please refer to the printscreen below)
And now, I have created under measures SumOf Tare that is using variable TareWt, and SumOfCargoWt that is using variable CargoWt.
I have tried to create another Measure SumOfGrossWt that would do a sum of variables TareWt + CargoWt but I have got some nonsense values.
I have tried to do another approach by creating variable GrossWt that would basically do exact the same thing as previous attempt
$V{Tare}+$V{CargoWt}
or use an variable: GrossWt
$V{Tare}+$V{CargoWt} or new Float($F{EquipmentTareWeightKg})+(Float.parseFloat($F{UfvFlexString03})+Float.parseFloat($F{UfvFlexString04}))
None of these actually worked: (Sum should be done by "Sum Of Tare"+ "Sum of CargoWt" = "Sum of GrossWt") plese refer to the second picture.
Here is a complete jrxml code/file:
jrxml file
save it as *.jrxml
Can please someone help me find a solution? how can I sum those two measure fields and get correct values?
Since CargoWt field had some null values in database, addition float value with null is equal to null, so the only value which was displayed on report are the one that had values for CargoWt, all others with null value were "ignored".
Here is a strange problem I have run into.
My record select formula is as follows, I have dumbed it down for purposes of this error:
reportDocument.RecordSelectionFormula = " {#ClientName} = 'Smith' "
If I copy this exact selection statement into Crystal it previews fine, but when run from .NET I get
'This field name is not known'.
The problem is occurring at the #ClientName formula field.
#ClientName simply contains:
formula = {aw_illust.CL1LNAM}
I can also set it to just a blank string (formula = "") and it still gives
'This field name is not known.'
Here is the strange part, if I bypass the formula and put the formula text straight into .NET everything works fine.
reportDocument.RecordSelectionFormula = " {aw_illust.CL1LNAM} = 'Smith' "
That is the same record selection, except with the '#ClientName' formula replaced with '{aw_illust.CL1LNAM}'. It just happens on this one report, I have many other Crystal Reports working with formulas referenced in .NET just fine. Any ideas?
Most likely you are not using your {#ClientName} formula anywhere on report; Crystal Reports tends to ignore unused fields, formulas etc. Place {#ClientName} field somewhere in report (header or some similar section) and suppress it - this way you don't mess up report design, but CR should know about that formula afterwards.
Which syntax has the formula? If it is crystal syntax then change it to basic syntax. Or change the content of the formula to crystal syntax (without "formula =")
You could create a parameter like {?ClientName} and set that from .NET, and then put a select formula in Crystal like {#ClientName} = {?ClientName}.
Can you save the report with the selection criteria you'd like then display what the reportDocument class sees using something like:
TextBox1.text = reportDocument.RecordSelectionFormula
This would confirm that your syntax is correct.
Same happened with me when I copied existing report to be used as the new one, You can first open report in report viewer ,In my case
but the query that loading report has no selection with name DateLocal Transaction so I got this error, the resolve is to either use only those that are require (Extras has nothing to do with the error) or rename selection value in query.