Variables with multiple conditions

Stimulsoft Reports.NET discussion
Post Reply
sbd_jeff
Posts: 27
Joined: Fri Nov 08, 2013 9:39 pm

Variables with multiple conditions

Post by sbd_jeff »

Hi Stimulsoft.
We've been implementing StiReports for the last month, and I've run into an issue that I have not found a technique for doing using Stimulsoft.

In Crystal, we could declare a variable ex. (@SomeName), and we could assign a value to that variable based on an infinite number of nested conditions. For example, if I have two database fields for a product name (ex. Products.Name and Products.VendorProductName) I could tell the Crystal variable to show "VendorProductName" if it is not null over "Name" like so:

Code: Select all

if not isnull({Products.VendorProductName})
then Products.VendorProductName
else {Products.Name}
In Stimulsoft, to achieve the same result, I have to use a ternary operator in an expression.

Code: Select all

!string.IsNullOrEmpty(Products.VendorProductName) ?  Products.VendorProductName : Products.Name
My users will not be able to do ternary statements.
My question is, is there a way to do more than one condition in a variable or other data structure within Stimulsoft where I can do something like:

Code: Select all

if(string.IsNullOrEmpty(Field1))
{
   if(string.IsNullOrEmpty(FIeld2)
   Field3;
   else
   Field2;
}
else
Field1;
Thanks!
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Variables with multiple conditions

Post by Alex K. »

Hello,

Please try to use the Switch function for this task.
Switch (condition1, value1, condition2, value2, ...)

Thank you.
sbd_jeff
Posts: 27
Joined: Fri Nov 08, 2013 9:39 pm

Re: Variables with multiple conditions

Post by sbd_jeff »

That works perfectly. Slowly but surely getting it.

Thanks!
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Variables with multiple conditions

Post by HighAley »

Hello.

We are always glad to help you.
Let us know if you need any additional help.

Thank you.
Post Reply