• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 226
  • Last Modified:

Microsoft Reporting Tool Expression

Hi there,

I'm new to Microsoft Reporting tool and I'm trying to create an expression which looks at a field on the report and returns a value of 0 if the field value is "CASH" and a 1 if the field value is "CARD".

It seems pretty straightforward but the formula never evaluates to 0, it always defaults to 1 even when the paymenttype field is CASH.

Is there a glitch in this program that anyone knows of where I have to do some kind of Cast or something?

My formula is:
=IIF(Fields!paymenttype.Value="CASH",0,1)

Thank you for your help.
0
boukaka
Asked:
boukaka
  • 2
  • 2
1 Solution
 
boukakaAuthor Commented:
I need to change my question!! I just found out that the field paymenttype.Value has 8 trailing spaces after the word CASH, my IIF formula now works.

HOWEVER, in order to avoid this problem in the future, is there a way to convert fields in these reports as you include them to remove extra spaces so that when I'm creating formulas I don't have to watch for hidden spaces?

Thanks!
0
 
Fernando SotoCommented:
Hi boukak;

I have not used Microsoft Reporting tool but when you need to remove spaces at the beginning and end of a string when assigning to a variable or retrieving it from a variable you can use the Trim function of String.

So in your statement
    =IIF(Fields!paymenttype.Value="CASH",0,1)
you can do this to remove leading and trailing spaces.
    =IIF(Fields!paymenttype.Value.Trim ="CASH",0,1)

Fernando
0
 
boukakaAuthor Commented:
Thanks!
0
 
Fernando SotoCommented:
No problem. Glad I was able to help. :=)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now