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

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.

Related

How to display parts of value from database with different font size in SSRS report?

One of my columns has a value that looks like this -> "$5.95 (Park costs)"
and I need to display the value in column in SSRS report like this:
$5.95
(Park costs)
but font size of "(Park costs)" must be smaller than the price.
Is something like that even possible? To somehow make text that does not contain a number, dot or dollar sign smaller?
You can do this. You'll need to split up each component of the text column and then place each half in a placeholder. You can then format each placeholder individually.
This solution assumes that your column always contains a "(". If not you should be able to modify it to suit.
I Generated some test data and and placed it in a normal table (tablix) control.
I then added some new columns for testing that each part was working as expected.
The expression for "Cost" column is
=TRIM(LEFT(Fields!MyColumn.Value,InStr(Fields!MyColumn.Value, "(") -1))
The expression for the "Caption" column is
=TRIM(RIGHT(Fields!MyColumn.Value, LEN(Fields!MyColumn.Value) - InStr(Fields!MyColumn.Value, "(") + 1))
Once this was working OK I added the "Final Column".
To add a placeholder, click inside the textbox so the cursor appears then right-click and choose "Create Placeholder"
I added two placeholders with a space between then and set the values to the expressions above respectively. I then right clicked the placeholders chose "Placeholder Properties" and formatted each individually.
The final output looks like this. (I left the test columns in for clarity)

Retrieving value including input mask from TextBox field - Access VBA 2016

I have an input mask of JAAA-AAA on a TextBox, so when the user enters that input field, they will see this: "J___-___".
However, when they fill it out like so, J123-321, and I get the value using [myfield].Value, it says that the value is only 123321. It strips the preset 'J' and '-' I had in there. How can I prevent the stripping of these characters when I retrieve the value from this field?
You need to set the second part of the input mask property to 0.
If you look at the documentation, you can see it has 3 parts, and the 2nd part controls if the mask is stored with the data, or only the data is stored.
The final mask property would be the following:
\JAAA\-AAA;0;_

Putting code in a text box (MS Access)

I am using a textbox for the header of my report, and based on what the user selects it will be "Baseline 8", "Baseline 9", etc. What I would like to do is have the text box coded so whatever number the user selects is entered into the text box. I managed to do it by using two text boxes, one just says "baseline" and the other text box says "=[Forms]![Navigation Form]![NavigationSubform]![Combo21]" and it will enter the correct value. But what I want to do is put it all in one box, and when I put "Baseline =[Forms]![Navigation Form]![NavigationSubform]![Combo21]" in the text box it doesn't work, it just leaves the code as the header when I generate the report. Is there something I'm not doing correctly?
First of all, when you state that a "textbox says", you really mean that "the Control Source property of the textbox equals." For a textbox (and some other controls), the value that you see on the actual form IS the Control Source property. I am not being picky for its own sake, rather it is important to recognize what value you are editing.
The Control Source property can essentially contain two types of values. The first is without an equals sign and it indicates the name of a field from the form Record Source. In that case, it binds the control to the field directly so that it automatically loads from the field and saves changes back to the field.
The second type of value always starts with =. It is a VBA code expression and can include calls to functions and other VBA operators. In your case, you want to concatenate (i.e. combine) two strings: one literal "Baseline" and one pulled from an access object [Forms]![Navigation Form]![NavigationSubform]![Combo21], so you need to use the string concatenation operator &.
="Baseline " & [Forms]![Navigation Form]![NavigationSubform]![Combo21]

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")

SSRS custom number format

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")