Is there any way that I can change a formula field with this code:
if(isnull(sum({col1}))) then
0
else
sum({col1})
to something like:
sum(col1) WHERE col2='a'?
I would like to calculate only some rows in the sum based on a value of another column.
In case there is, please provide me with syntax or the way to do it.
P.s: in case it matters I'm using CrystalReports 13.0 whith Visual Studio 2010
You can do something like this.
In details write formula
If col2='a'
Then col1
Else 0
Now take the sum in footer
Related
I am using crystal reports plugin in visual studio to develop crystal reports.
In my report, there are three group by functions. The hierarchy is shows below -
Employee.EmployeeType
Employee.EmployeeCity
Employee.OfficeBranch
I need to calculate percentage of Seats occupied in every branch per city. The condition is that only those seats should be considered that have seatnumber greater than 5.
I am using the following formula but it is giving me error saying ) expected -
#seatNumber
if({Employee.SeatNumber},{Employee.OfficeBranch})>5
then
count({Employee.SeatNumber})
else
0
I know we have to use if ({key field}, {Group field}) and then we have to create another formula which we will use to sum(#seatNumber).
and then will have to use both to calculate percentage per group. But I am stuck.
if({Employee.SeatNumber},{Employee.OfficeBranch})>5
is not a valid expression.
You probably meant something like:
if {Employee.SeatNumber} > 5
Since you wish to ignore seats 1-to-5 it would be a lot simpler to just add this condition to the record selection formula:
{Employee.SeatNumber} > 5
I have this concern using Crystal Report which I am not really familiar with. Here's my scenario:
I have an existing report to update, I need to add a column (ETA) which has a datetime value. It may return more than one rows per Item No, I need to get the minimum date only per Item No from the result rows.
I already tried some solution mentioned here http://scn.sap.com/thread/1952829 but found no luck.
I used a suppression formula for the Details section of the report, but haven't succeeded yet.
IF {TableName.DateField} = Minimum({TableName.DateField}) THEN FALSE ELSE TRUE
Any possible things you can suggest me to try? Thanks in advance for this :)
good to get this value from sqlserver side. you just create a function which return a single data (minimum date).
If you wish in crystal report side, it is something you make loop of hundred for a single row display. You can use running total field for this.
Select the field , select summary type and put into the detail section.
or you can create a formula with group name option like
Minimum({TableName.DateField})
http://scn.sap.com/thread/1952829
http://businessintelligence.ittoolbox.com/groups/technical-functional/businessobjects-crystal-l/unable-to-filter-based-on-the-first-date-in-list-of-dates-4912881
please check
Running total field gives options for Min, Max, etc. but not Sum
http://flylib.com/books/en/4.229.1.28/1/
I'm using Crystal Reports 12.3 and Peachtree Accounting 2012 to manage some database. My task now is simply make a report that contains customers that have not placed orders in last 30 days. I'm new to it so I'm asking your help.
My first trying was to use this formula (I'm doing all my stuff in Formula Editor -> Record Selection):
not ({Customers.LastInvoiceDate} in Aged0To30Days)
Everything seems to be fine except null values. I need to include in report records with null values. So I rewrite the formula to:
not ({Customers.LastInvoiceDate} in Aged0To30Days) OR IsNull({Customers.LastInvoiceDate})
But in Peachtree Accounting 2012 I'm seeing a customer with a blank LastInvoiceDate field which is not in report.
Is there some kind of bug in my last formula? Or is there some "other" black values for DateTime type?
You should always check for nulls first, so try reversing the second formula to
isnull({Customers.LastInvoiceDate}) or not({Customers.LastInvoiceDate} in Aged0To30Days)
If Crystal encounters a null and it is not explicitly handled first, then the rest of the formula will crap out and not evaluate. Another way to get around this is to tell Crystal to use 'Default Values for Nulls' instead of 'Exceptions for Nulls' in the Formula Workshop (It's a dropdown setting in the Formula Workshop toolbar).
length(trim({Customers.LastInvoiceDate})) = 0
One statement with no need for isnull function and OR operator.
How to get the result using formula field in crystalreport
for counting number of records where fieldname =xxx
like: select count(*) as cnt from tbl where f1=xxx
and explain more with examples for crystal report count() function.
Project: VB.Net
regards,
Sensa.
you basically create a formula field like:
if {mytable.field} = 'xxx' then
{mytable.field};
then count({formula});
or use running totals with an evaluation formula: {mytable.field} = 'xxx'
You can try this:
FormulaField1:
if {anytable.yourfield} = 'xxx' then 1 Else 0;
And then:
FormulaField2:
sum({formula1});
For integer:
FormulaField2:
CSTR (sum({formula1}),0);
There are several alternatives each with certain drawbacks.
1) Use the select expert to restrict the records in the report conditionally.
The major drawback in this case is of course loss of data probably relevant to other parts of the report
2) Solution 1) using a sub-report integrated in the main report.
The problem in this case is formatting constraints
3) Use grouping. I.E. group by mytable.field use a running total on the records
withing the group and insert to group header. Hide the group selectively trough the section expert.
Here again arises the problem of additional formatting constraints.
4) Finally if you have access to the actual database. Create a view, this will be the best solution in terms of performance and issues with formatting within crystal reports.
However creating a view each time this kind of problem arises can lead to polluting your database with views which will only be used infrequently.
I work on an accounting project in .NET.
I want to sum all transaction and its opening balances.
I use summary but it Allows only one column..
You can summarize within formulas, so long as the formula field is present in the report footer. When using Sum() CR knows to evaluate the expression for all records returned.
So you would create a formula for the report footer, and the formula code would be something like:
Sum({#TransactionAmt1}) + Sum({Transactions.Amount}) + Sum({#AnotherFormula});