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.
Related
In a C# RDLC file, I have set up a report variable called test.
I have a table and based on the value in the row. I want to set the report variable.
Below is a field from the table. I check to see if the first letter is H, and set the variable to 1, otherwise, it displays a value 2.
=iif(Left(Fields!StockSymbol.Value,1)="H",Variables!test.Value = 1, "2")
So what happens is that test is not equal to 1, so the grid prints false. I actually, want it to print false and set the test variable to 1.
Anyone know how?
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.
Why does a value from a certain Winform change when passing to a report?
for example from a form I have a string 1311-0015 but when I pass it to a Formula Field it becomes 1,296.00
http://i.imgur.com/oeIwrAU.jpg
Passing it to a TextObject doesn't change the value it's still 1311-0015 but I can't use TextObjects in formulas in Crystal Report.
Would like to know why this is happening and how to remedy the problem.
this is the code from the winForm:
report.DataDefinition.FormulaFields["SOS"].Text = transactionId; ((TextObject)report.Section2.ReportObjects["Text3"]).Text = transactionId;
the value I was passing to the crystal report:
public string transactionId = "1311-0015";
You said you are passing the value to a formula field. If there is nothing in the formula, and you pass 1311 - 15 to the formula, it will evaluate it. Instead of a formula field, use a text box or modify the string so it doesn't come out like an equation. For your transactionID value try something like:
""1311" & "-" & "0015""
You may need to have two separate public string transactionId variables.
You can pass this string as parameter.
First, create a parameter field in you Crystal Reports editor. (Right button, New...)
Code something like this:
string transactionID = "1311-0015";
yourRpt.SetDatasource(youDataSource);
yourRpt.Parameters.SetParameterValue("transactionID", transactionID);
Now, you just need to drag and drop the parameter field into the report.
You should create a parameter and use its value inside the formula.
In order to avoid showing parameters dialog box make sure that the parameter value is set (you should do this in your code) and set:
yourReport.EnableParameterPrompting = false;
I have a DataGridView and added a column called SellQty and a Checkbox at index 0. User has to enter int value when he selects a checkbox. If not I am showing a message to enter the value. Now the problem is I am getting the value from the SellQty cell and storing it in an object and checking whether it is null.
object SellQty = gvProductBatch.Rows[i].Cells["txtSellQty"].Value;
if(SellQty!=null)
// do something
else
// ..Show message.
This works fine. But the problem is when the user enters a value and deletes it, the value stored in it is {} i.e. empty. I would like to know how to check an object is empty. I have googled for the same but didn't find answer to handle empty object. All results were for if object is null.
You can get the actual edited Value by using the .EditedFormattedValue
if (string.IsNullOrWhiteSpace(gvProductBatch.Rows[i].Cells["txtSellQty"].EditedFormattedValue.ToString())
{
//Do something
}