how to get runningvalue() in crystal report - crystal-reports

I use RDLC reports in past but now i am using Crystal report. i use this formula in RDLC report
=Previous(RunningValue(Fields!balance.Value,sum,nothing))+Fields!balance.Value
but not find Running value in Crystal report. can anyone tell me where is it in crystal report? if not any other solution to do this?
i want result like this in balance column
id name debit credit balance
1 umer 100 0 100
2 umer 0 50 50
3 umer 0 10 40
4 umer 200 0 240

I'd suggest you use a Running Total for this as this type of calculation is exactly what they're intended to be used for.
First, create a formula that will handle the debits as addition to the total and credits as subtractions: {table.debitAmount} - {table.creditAmount}
Then create a Running Total and plug the formula you just created into the "Field to summarize". In the "Evaluate" section of the Running Total screen, keep it set to "For each record" and in the "Reset" section, keep it set to "Never" if you want this balance to work over the entire report or pick a group if your balance should be by a grouping level.
EDIT: It goes without saying, but you'll want to verify that the "Type of summary" to be set to "Sum"

Write below code in Balance
Whileprintingrecords;
Shared Numbervar balance;
Shared Numbervar display;
balance:=debit-credit;
display:=display+balance;
display

Related

Grand total with each summation in crystall report

I have data like this
Type Buy Sell
Car1 23000 15000
Car2 24000
Car3 25000
I used sum(#buy) for total buy field and sum(#sell) for total sell field.
Can I sum all or grand total that like sum(#buy) + sum(#sell) ?
because when I run in VB6 for preview that report, Grand total not show on, please help me master.
For this there are 2 approach.
Via Formula :- add a formula field and in that add give above condition in formula field editor. put this field in your desired location, but ideally put in report footer or group footer(if any).
Use running total or summary total.
Check this links
Crystal Report Sum of a Column data
https://forums.asp.net/t/1971464.aspx?Sum+of+Total+in+Crystal+Report+

Crystal Reports 2008 running total using datediff returns only 1

I have a running total set to count employees with less than 30 days between two events. While the report has groups, I have the running total set to never reset. I am using a formula in the Evaluate section that is as follows:
DATEDIFF("d",{Employee.DATE_Event1},{Employee.Date_Event2}) < 30.
This running total returns 1 when placed in the report header and 1400 when placed in the report footer. 1 is far too low and 1400 is far too high. The requester wants the total in the report header. Thoughts?
if you keep your formula in header.. it will display 1st record and if you place in footer then it will display last record.. that is how it works.. so you get 1 and 1400...
You are trying to display a value when it is not actually calculated because as the running total reaches the footer value then you will get the fully calculated value....
what you can do is create a sub report and place it in header and supress the sub report... Perform the same calculation that you do in the main report and pass the sub report value to main report and take one more section of header after sub report section and display there your value..
With this approach load on database and report will increase as you are performing the same operation twice

How to calculate % with count base on condition?

I use crystal report, my report have 2 fields : man=3 and woman=4. I want to calculate % man? with formula field. I try count({person.sex},"man")*100/count({person.sex}) but show Error "A field is required here"? Help me!
Take 2 running total variable, put into the group footer or appropriate section (preferable on any footer- report footer will display total percentage, not group wise) and give condition as you want or check below links.
Using a Running Total in a Formula in the Details Section of a Crystal Report
How to sum running total field for each group in crystal report?
http://community.spiceworks.com/topic/117306-crystal-reports-won-t-summarize-or-running-total-my-formula-field
please check this link
http://crystalreportsblog.com/crystal-reports-running-totals/
http://www.experts-exchange.com/Database/Reporting/Crystal_Reports/Q_28044491.html

How to get individual group totals in report

I have a jasper report being made with iReport, which is basically a list of pages received the day prior. The report has total pages for the whole day and then individual totals for each group of page types.
The requirements state I need to display all the totals above the listed records and groups (ex. display in the title band). I created a variable for the total of all pages and that works but am having trouble getting each individual group total.
It should look like:
Total pages received: 50
Total GROUP_A: 20 Total GROUP_B: 30
When I try to use the variable set up for group totals, it only gives me the last used group, so it would say 30. I'm unsure how to create a variable to get the total for only a specific group.
I could include in my SQL result set the totals but was asked to do it within iReport.
If I understand the problem right you need to put a copy of the variable that you are using in the group and put it in your title band. the trick is on the object in the title band make sure you have set the evaluation time & evaluation group group or report depending on what you are truing to get a total of.

This field cannot be summarized in crystal report errors

I was be able to output a crystal report and this is about accounting logic.
some of the column appear in my crystal report is eg.
accountname debit credit
cash..........1000...300
I want the column debit minus column credit (1000-300)
if the result is positive (+) then 700 will appear in that debit column
If the result is negative (-) then the value appear in credit column and i wan to remove the negative sign. So above value 1000 and 300 is not what i wan to show and debit or credit will be 0 eg
accountname debit credit
cash...........700......0
Above case is ok so far and now i end up like this
In crystal report formula editor i have #creditbalance, and inside it has formula:
if Sum ({Entries.Debit}, {Entries.AccountName})>Sum ({Entries.Credit}, {Entries.AccountName}) then
formula= Sum ({Entries.Debit}, {Entries.AccountName})-Sum ({Entries.Credit}, {Entries.AccountName})
end if
So it can give me as i wanted to show (the 700 and 0 part)
The problem is i create another formula
#TotalDebitBalance
Sum ({#DebitBalance})
It error said "This field cannot be summarized", Then how to sum up the value i get from #debitBalance.
Note: #TotalDebitBalance i plan to put it at report footer section where all grant total usually placed there, where #debitbalance i put it at Group Header section.
Right click the report.
Insert.
Summary Fields.
Select the formula you have done on the field and change from max to sum
Change Location to Group Footer
Do the same again and this time select the Report Footer
You will have two fields, one for the group footer and other for report footer, hope this helps.
It doesn't say but I'm assuming the report is grouped by {Entries.AccountName}. In addition to Waqar's solution, I'd replace the formula with something easier.
{#DebitBalance}
IF {Entries.Debit} > {Entries.Credit} THEN
{Entries.Debit} - {Entries.Credit}
ELSE
0
{#CreditBalance}
IF {Entries.Debit} < {Entries.Credit} THEN
ABS({Entries.Debit} - {Entries.Credit})
ELSE
0
In the details section, replace the {Entries.Debit} and {Entries.Credit} with {#DebitBalance} and {#CreditBalance} repectively. This will give you the
cash...........700......0
Then do as Waqar mentioned to summarize the formula. It's easier to use the Group... and Summary... features than to do it manually in the formulas.