IIF Function

Stimulsoft Reports.WEB discussion
Post Reply
davidanthonyb
Posts: 22
Joined: Sun Apr 03, 2016 2:09 pm

IIF Function

Post by davidanthonyb »

Hello,

I am trying to find each line item of type "Return", and multiply the quantity by -1 if true, by +1 if false.

I am using the following expression in my databand filter:

Code: Select all

IIF((Table1.InvHistoryTypesInvHistoryType == "Return"), ((Decimal)Table1.InventoryHistoryQuantityChange * (-1)), ((Decimal)Table1.InventoryHistoryQuantityChange * (+1)))
I am receiving the error: "Cannot implicitly convert type 'object' to 'bool'
What cast am I missing or doing wrong?


Thanks,
David
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: IIF Function

Post by Alex K. »

Hello,

Please send us your report with test data which reproduces the issue for analysis.

Thank you.
davidanthonyb
Posts: 22
Joined: Sun Apr 03, 2016 2:09 pm

Re: IIF Function

Post by davidanthonyb »

Aleksey wrote:Hello,

Please send us your report with test data which reproduces the issue for analysis.

Thank you.

Hi Aleksey, thanks as usual for the response!

Attached is a version of the report that is receiving the casting error.

The image below is almost what I need.
https://ibb.co/jqH5ka

But what I need to do in the designer is change the quantity of all return transactions to a negative.
The ultimate goal would be to add a group summary summarizing the positive int issue transactions, and the negative int return transactions.

i.e.
return -10
return -5
issue 25
total 10



in addition to the IIF function, I did also try using the ternary operator, but ran into the same error. I am open to any other suggestions!

Thanks in advance!
David
Attachments
TestReport.mrt
(17.91 KiB) Downloaded 350 times
davidanthonyb
Posts: 22
Joined: Sun Apr 03, 2016 2:09 pm

Re: IIF Function

Post by davidanthonyb »

Sorted it out!

I applied this directly to the Quantity data source, instead of adding to the databand filter :)

Code: Select all

{IIF((Table1.InvHistoryTypesInvHistoryType == "Return"), (Table1.InventoryHistoryQuantityChange * (-1)), (Table1.InventoryHistoryQuantityChange * (+1)))}
Thank you though for your response!
:)

David
Andrew
Posts: 4109
Joined: Fri Jun 09, 2006 3:58 am

Re: IIF Function

Post by Andrew »

You are welcome, David!

Have a nice day!
Post Reply