Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1708
  • Last Modified:

SSRS Format Text Box value

I have an if statement that if yes, provides a value. I set the number format to percentage in the text box properties. How can I through code,  if no, set the value to show N/A? I know I would need to change the format of the text box and provide "N/A" as a value.


So, if value > 0 then number%, else N/A.
0
LCNW
Asked:
LCNW
1 Solution
 
Tony303Commented:
The expression for the value of the field should read somthing like this...

=IIF(Fields!YOURFIELDNAME.Value) > 0, Fields!YOURFIELDNAME.Value, "N/A")

Just try it and see if the number format for that field is going to be a pest.
0
 
selva_konguCommented:
select the text box and go to the expression (Right click on the text box and select from Menu)
RMC in txt boxit will open expression window there you can add the format expression
expression window
=IIF(Fields!scnnumber.Value > 0, (Fields!scnnumber.Value & "%") , "N/A")

Open in new window

here scnnumber is sample field which I Used.

replace your field name and test the report.

---- SelvaS---
0
 
ValentinoVBI ConsultantCommented:
In case you're still wondering how you can get your percentage formatting to work, have a look at the following expression:

=IIF(Fields!YourValue.Value <= 0, "N/A", Format(Fields!YourValue.Value/100, "P0"))

Open in new window

As you can see, the Format function can be used to achieve your requirement.  Now, how does that work?

I'm dividing the value by 100.  This may or may not be needed, depending on the content of YourValue.  If YourValue is a percentage representation in the zero to one range, with 1 meaning 100%, then the division is not needed.  However, if YourValue contains 100 to indicate 100%, then it is needed.
Through "P0" (that 0 is a zero) I'm telling the function that I want a percentage without any decimals.  Depending on your requirements, you may want to increase the zero to the number of decimal digits expected.
0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
LCNWAuthor Commented:
ValentinoV ,that's what I needed. Where can I get a list of all formatting options such as P0? Or, what is it called so I Google the correct terms. Searching for SSRS formatting gave me the wrong info.
0
 
ValentinoVBI ConsultantCommented:
Cool, glad to hear I was on the right track with my answer :)

The Format function is one of the Visual Basic string functions, so you'd have to refer to the doc for that function: Strings.Format Method
0
 
ValentinoVBI ConsultantCommented:
Here's a trick that can be used in Google: copy the function description from the Expression builder and paste it into the search box, surrounded with double quotes.

Example:

"Returns a string formatted according to instructions contained in a format String expression"
0
 
ValentinoVBI ConsultantCommented:
And as usual, MS has got too many pages that describe more or less the same functionality. It was really hard to find a reference to that number to specify precision following the P format specifier.  The best one is probably this one: Standard Numeric Format Strings
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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