SSRS custom number format - reporting-services

I am go to generate an excel file from SSRS, and
I want to format the number like this...
15 is displayed as 15
14.3453453 is displayed as 14.35
12.1 is displayed as 12.1
0 is displayed as 0
1 is displayed as 1
I can apply this in Excel but unable to apply in SSRS
[=0]0;[=1]1;0.##
Does anyone can suggest another way for me? Thanks!

am assuming that you want to know how to format numbers in SSRS
Just right click the TextBox on which you want to apply formatting, go to its expression.
suppose its expression is something like below
=Fields!myField.Value
then do this
=Format(Fields!myField.Value,"##.##")
or
=Format(Fields!myFields.Value,"00.00")
difference between the two is that former one would make 4 as 4 and later one would make 4 as 04.00
this should give you an idea.
also: you might have to convert your field into a numerical one. i.e.
=Format(CDbl(Fields!myFields.Value),"00.00")
so: 0 in format expression means, when no number is present, place a 0 there and # means when no number is present, leave it. Both of them works same when numbers are present
ie. 45.6567 would be 45.65 for both of them:
UPDATE :
if you want to apply variable formatting on the same column based on row values i.e.
you want myField to have no formatting when it has no decimal value but formatting with double precision when it has decimal then you can do it through logic. (though you should not be doing so)
Go to the appropriate textbox and go to its expression and do this:
=IIF((Fields!myField.Value - CInt(Fields!myField.Value)) > 0,
Format(Fields!myField.Value, "##.##"),Fields!myField.Value)
so basically you are using IIF(condition, true,false) operator of SSRS,
ur condition is to check whether the number has decimal value, if it has, you apply the formatting and if no, you let it as it is.
this should give you an idea, how to handle variable formatting.

Have you tried with the custom format "#,##0.##" ?

You can use
=Format(Fields!myField.Value,"F2")

Related

how to solve SSRS Formatting issue?

Currently the data in field is coming like this 9646.88 and my requirement is
Remove decimal places and add comma for thousands e.g. 9,646
=IIF((RTRIM(Fields!COMPANY_NAME.Value))="VACANT","",Fields!BASE_RENT_PM.Value)
Please help, I am a newbie in SSRS.
Go to Properties pane when you select the textbox.
Then put this on Format property
#,0;(#,0)
Using Common Functions such as Text and Conversion functions shown in Expression window will give you the desired result.
For e.g,
Format(Int(9646.88), "#,###") // try "#,##0" which returns 0 if less than 1
where Int(9646.88) returns the integer portion of the number 9646 and Format(9646,"#,###") returns a string formatted according to instructions contained in a format String expression "#,###" which is a thousand seperator. Thus, it will give you "9,646".
So, in your case, try this,
=IIF(RTRIM(Fields!COMPANY_NAME.Value)="VACANT", "", Format(Int(Fields!BASE_RENT_PM.Value),"#,###"))
Note:
Format(9646.88, "#,###") will return a rounded result 9,647 and
Format("VACANT", "#,###") returns just "#,###",
none of which may not be your desired result.
Have your Tried this?
=FORMAT(IIF((RTRIM(Fields!COMPANY_NAME.Value))="VACANT","",Fields!BASE_RENT_PM.Value),"#,###")
Should solve your issue.
Kind Regards
To add comma for thousands, you need to change your expression.
If you need output as 9,646 then try below.
=IIF(RTRIM(Fields!COMPANY_NAME.Value)="VACANT","",Format(Convert.ToInt32(Int(Fields!BASE_RENT_PM.Value),"#,0;(#,0)")))
OR
=IIF(RTRIM(Fields!COMPANY_NAME.Value)="VACANT","",Format(CInt(Int(Fields!BASE_RENT_PM.Value),"#,0;(#,0)")))
Updated Answer:
As you want to handle null values as well I would suggest below way to achieve your goal.
Set Textbox visibility with below expression.
=IIF(ISNOTHING(Fields!BA‌​‌​‌​SE_RENT_PM.Value),True,False)
So if null value is there then it will show blank in the ssrs report.

how do I change a lookup value to whole a number in ssrs?

How do I format a number with 2 decimal places to a whole number?
I used the Lookup function to get a result, but formatting decimal to whole number does not work for this value. I did Text box properties -> number -> whole number doesn't work for one of my value. Also customize number to #,### but its not changing anything.
How do I make this value display as a whole number?
You may be confusing how the number is displayed (which can be controlled using text box properties) and it's actual value. It sounds like the value returned from the lookup is not a number, it might be a string/text value instead which would explain why it was not affected by number formatting.
One option is to convert the value to an integer (whole number) in the lookup expression itself, using a function to convert the value: CInt()
For example if your expression currently looks something like this:
=Lookup(Fields!SomeField.Value, Fields!SomeDatasetField1.Value, Fields!SomeDatasetField2.Value, "SomeDataset")
then you can change it to:
=CInt(Lookup(Fields!SomeField.Value, Fields!SomeDatasetField1.Value, Fields!SomeDatasetField2.Value, "SomeDataset"))
Or if you want to keep the original value, but just change how it is displayed then convert to a decimal value instead:
=CDec(Lookup(Fields!SomeField.Value, Fields!SomeDatasetField1.Value, Fields!SomeDatasetField2.Value, "SomeDataset"))
and then use the text box formatting options to control the displayed format.

SSRS number format expression showing unexpected results

I have a table that contains metric data for various business units in our organization. There is one column that contains the KPI measurments. I've created a report to display each business units KPI's. Some of the metrics need to be displayed as whole numbers, others need to be displayed as percentages.
I created an expression to handle the multiple formats. The problem I'm having is with the percentages. For example one of the numbers (which should be displayed as 93.74%) appears as 939474%. If I remove the expression and set the format to percentage using the text box properties, the number displays as 93.74%.
Here is the expression I'm using:
= IIF(Fields!KPI_desc.Value like "*Rate",
Format(Fields!Value.Value,"0.00%"),"0")
Any suggestions would be appreciated.
Thank you
I guess you put this into the Format Expression so that it will return the result like integer. Actually you just need to put this expression into textbox directly.
= IIF(Fields!KPI_desc.Value like "*Rate", FormatPercent(Fields!Value.Value,2),"0")

How to remove trailing zeros using ssrs?

I have a column DECIMAL(18,4). when I insert data like 123.45 it becomes 123.4500
I want to show it in SSRS like 123.45.
How to remove those zeros in SSRS?
Depending on what exporting formats your need you can set the number formatting to 0.####;(0.####)
I know this is compatible with the SSRS viewer and exporting to PDF, but Excel would take 123.0000 and show it as 123. instead of just 123
I dont agree with the accepted answer, casting to a string is another workaround:
=Str(NumericValueWithVariableDecimalPlaces)
Unfortunately a consequence is no numeric formatting settings will apply and setting cell Alignments to right causes numbers to be misaligned.
You can change the data type returned to SSRS to a FLOAT. That should do it :-)
Open SSRS Query Designer and add:
SELECT CONVERT(DOUBLE PERCISION,FIELD) FROM TABLE SOURCE
OR add to your select result from your Store Procedure source
SELECT CONVERT(DOUBLE PERCISION,FIELD) FROM TABLE SOURCE
This will remove trailing zeros: CDbl(Fields!YOURFIELD.Value)
This can be done in the SQL which you can do by casting the value to DECIMAL(18,2)
ex:
CAST(FieldName as DECIMAL(18,2))
but if you really want to do it in SSRS. You can right click on the textbox that the field is displaying in and go to textbox properties. In the pop-up box choose 'Number' and set the Category to 'Number' and then decimal places to 2. This should correctly display the value.
You could also right click on the textbox and go to expression and say this in the expression popup box:
=FormatNumber(Fields!FieldName.Value,2)
I try and find solution:
I use Expression for value:
=IIf(IsNothing(Fields!FieldName.Value), "", IIf(IsNothing(Fields!FieldName.Value), "-", CInt(Fields!FieldName.Value * 10000) / 10000))

MS Access VBA Cross tab report legend sort order

The problem is hard to explain ,
I have an access report with a stacked bar chart to show the percentage fills over time like the one in this example : Click here
The legend for the chart i have is a number followed by the name, for e.g
1-Mango
2-Apple
3-Banana
etc
I want to sort this according to the above format but when i have more than 10 items the 10-Pineapple comes before 1-mango when it should appear after 9-somefruit .
The underlying query for the access report uses a Cross Tab query in which the items are created as
Column heading:[PrefixPriorityNumber]&"-"&[FruitName]
I even used the Sort:Ascending but it still doesnt affect my custom ordering that i wanted to show.
I also tried to google "sorting alpha numeric strings" but this is clearly more than that.Any assistance is appreciated
The problem is you are getting a text sort. You need to format the prefix number.
Column heading: Format([PrefixPriorityNumber], "00") & "-" & [FruitName]
Either use another digit, as Remou suggests (01 instead of 1) or start using letters. A > 9, B > A, etc.