I create a formula for conditional sum. Here is sample code.
` if {Customer.Region} = 'VA'
then 1
else 0
To sum records in the state of Virginia:
if {Customer.Region} = 'VA'
then {Orders.Amount}
else 0`
I want to input the value 'VA' from textbox of a form dynamically. When i input 'VA' in my form and click a button that value go to the formula if {Customer.Region} = 'textbox Value'. How can i do that?
Create a Parameter Field. This will allow you to be prompted by the report to input a value. So if you created a Parameter Field and name it "MyString", then you could do your comparison to your report field as:
If {Customer.Region} = {?MyString}
//Do something if true
Else
//Do something if false
Please note, this will only prompt you to input a value for the Parameter Field when the report is executed. If you want to compare using a second input value, you will need to run the report again for each additional value.
I have created one crystal report where I want to write a formula.
my formula:
IF {Sp_Get_DailyReport;1.Job_Status} = 'Workshop'
THEN {Sp_Get_DailyReport;1.Department_Name}
but, this formula doesn't returning a value.
i have edited my formula, now i'm getting as 'false' instead of Dept-name.
stringvar text := "";
IF {Sp_Get_DailyReport;1.Job_Status} = "Workshop"
THEN text = "{Sp_Get_DailyReport;1.Department_Name}"
In ReportFooter i have created one column for workshop where i want to display department name n unit name whose units are in workshop and i'm placing this formula field in ReportFooter where its returns only one value,
instead of each condition where its true &
why its returning 'false' i dont know, instead of dept name.
I want to select all those records whose jobstatus is workshop n display it in the reprotfooter.
Can anyone please help me...
Thanks
TROUBLE SHOOT
IF {Sp_Get_DailyReport;1.Job_Status} = "Workshop"
THEN {Sp_Get_DailyReport;1.Department_Name}
ELSE
{Sp_Get_DailyReport;1.Job_Status}
This function will return the value of the Job_Staus if the Job_Status value is anything BUT "Workshop"
Are you sure the Job_Status value contains "Workshop"
Check for Spaces as Well could try trimming Job_Status
I have a simple search box in my web app and i want to provide options of searching the employee table for either name, employee id or position etc. Ie, basically a drop down and then a text box to enter the value. The columns currently being chosen are from the same table.
I have assumed i need 2 parameters equating both such that one refers to the column name and the other to its value. Is it right? And if so, how do we pass the sql query on formula editor?
Check the below code:
if ({?cat}="NAME")
then
{FATHIMA.NAME}={?val}
else
if({?cat}="POSITION")
then
{FATHIMA.POSITION}={?val}
Provided there should be value in {?val} and that value should match with the value in database.
Yes i have used Record Selection Formula. The code I've written there is:
if ({?cat}="NAME")
then
{?val}={FATHIMA.NAME}
else
if({?cat}="POSITION")
then
{?val}={FATHIMA.POSITION}
---where "NAME" and "POSITION" are column names. I have passed them manually as items in a drop down list. But the report gives an empty result. 'cat' is the parameter holding the selected value from the drop down.
In my Crystal Report, I want to show the Field values in Upper Case.Is there any way to do this?
You don't need to create a separate Formula Field to achieve this result.
Instead, add the following to the field's Display String conditional formula:
UpperCase(CurrentFieldValue)
Here you go ... http://www.crystalreportsbook.com/Forum/forum_posts.asp?TID=8823
You will notice in this example they are using the UpperCase function of Crystal Reports. So, all you need to do is say UpperCase(some field name) and that take care of it for you.
I have added a parameter to my report with the option "Allow Multiple Values" checked.
This is a status column (IE, Proposed, In Progress, Completed, Canceled), and I want the user to be able to select which (and how many) different OrderStatus to report on.
How I normally set parameters is:
report.SetParameterValue("#dtBegin", dtBegin.DateTime);
What I tried to do for the multiple values was something like this:
//pseudo loop
foreach(int intOrderStatus in intSelectedOrderStatuses)
{
report.Parameter_OrderStatus.CurrentValues.AddValue(intOrderStatus);
}
I have checked it does add the values to the OrderStatus parameter, but when the report runs, the CrystalReports dialog pops up and asks me to enter values for the OrderStatus parameter. So it seems as though the values aren't "commited" to the parameter. I have done a number of searches and can't figure out why it's not working.
Thanks,
Just set the parameter value with an array of ints.
report.SetParameterValue("#OrderStatus", new int[]{1,2,3});
in the select expert you would use the in operator.
{table.order_status_id} in {?#OrderStatus}
What you can do is, make a normal parameter field,i.e without multiple values, only discreet values true, all you need to pass is 1,2,3,4. "," is the delimiter for separation use what ever you think works for you, then in record selection formula simply put
{table.order_status_id} in split({#OrderStatus}, ",")
all you need to pass from you page is the string 1,2,3,4 and it should work
Have you set the parameter to Hidden in the Crystal Reports parameter options?
I haven't tried this, but I think that you should be able to add intOrderStatus to either a ParameterDiscreteValue or ParameterRangeValue and pass that into Parameter_OrderStatus.CurrentValues instead of intOrderStatus.
Well i have same issue. The work around is very simple. Don't add data source after parameters. e.g
report.SetParameterValue("#dtBegin", dtBegin.DateTime);
report.SetParameterValue("#dtBegin2", dtBegin.DateTime1);
//Note datasource is assigned after parameters
report.SetDatasource(dataset);
The crystal report will refresh parameters before applying data source to report.
The below is the not popup discrete dialog box
//Note Datasource is applied before parameters
report.SetDatasource(dataset);
report.SetParameterValue("#dtBegin", dtBegin.DateTime);
report.SetParameterValue("#dtBegin2", dtBegin.DateTime1);
Following is tested in Crystal Reports version 13.0.20:
1) In Parameter Fields section add new parameter as follow:
Name: ParamMultipleOrderStatus
Type: Number
Value Options:
Allow multiple values: true
2) Choose the Select Expert Record ... in Crystal Reports and code may like this (use = operator):
{Orders.OrderStatus} = {?ParamMultipleOrderStatus}
3) Use following code:
foreach (int intOrderStatus in intSelectedOrderStatuses)
{
report.ParameterFields["ParamMultipleOrderStatus"].CurrentValues.AddValue(intOrderStatus);
}