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

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)

Related

How to generate numbers for showing sequence in SSRS also it should get rearrenge when any field inbetween is missing

I am facing problem in SSRS report for showing sequense numbers as given in image.
when I searched for this issue I got solution as -- RowNumber("DataSetName")
but problem with this is, it generate numbers like 1,2,3..., but I want these numbers in following forms- 1.1, 1.2 or 1.1.1, 1.2.1.
And another problem for me is above function will work if I am having multiple rows in dataset and that dataset is bind with table to show its data, but In my case I am getting all data in single row and out of that I am showing values in textbox using expressions and if that value is empty I am hiding that textbox.
so I am not getting any solution to show sequence number in textbox along with text and how I can rearrenge that numbers if my inbetween textbox is hidden because of no data.
Please provide me solution for above probem.
Image for reference -
Example of data is :
From above table values from "Subheading1" And "Subheading2" will show inside "Heading first" and "Subheading3" And "Subheading4" will show inside "Heading second".
You can concatenate row numbers as strings as follows:
=RowNumber("HEADING") & "." & RowNumber("SUBHEADING")
To ensure numbers are consecutive remove the relevant rows in the source dataset instead of hiding them in the tablix.

Creating a percentage in an expression

Would like to have some text in my report like the following where the percentage is based on an expression. I would like to know how to work out the percentage.
60% of letters were sent with a first class stamp
This is an example of the figures I'm working with
First Class 300
Second Class 150
Other 50
The fields used are 'StampType' and 'RefNo'. The totals are gathered by a count on the 'RefNo'
To do this, do the following steps.
First, add a new Text Box to the report. Click inside the text box so the cursor shows inside. Right-click and choose Create Placeholder.... Enter the following expression for the Value field.
=Lookup("First Class", Fields!StampType.Value, Fields!RefNo.Value, "ReportMain") / Sum(Fields!RefNo.Value, "ReportMain")
This assumes the dataset name that is returning your data is named ReportMain. Change this if needed.
This looks up the First Class RefNo value from the dataset, and then divides that by the total of the RefNo in the dataset.
Go to the Number section of the dialog, change the Category to Percentage. Adjust the Decimal places to your liking. Click OK.
Type the text you want to follow that value after the placeholder (not in the placeholder) in the text box. Like this:
Preview the report, and you should have what you need.

Microsoft Report Designer Line Through Text when value not Empty

Has anyone used LineThrough text on Microsoft Report Designer within the expression value?
Example:
=Switch(Fields!a.Value is Nothing, "text here".LineThrough, Not(Fields!a.Value is Nothing), CStr(Fields!a.Value))
I need the "text here" to be strikethrough if a.Value is nothing.
You need to use an expression to show the value you want and then Harry's answer to set the LineThrough.
You can simplify your SWITCH statement for the value like this..
=SWITCH(
Fields!a.Value Is Nothing, "Text Here",
True, Fields!a.Value)
or if the expression will not get any more complex than you have then use IIF
=IIF(Fields!a.Value Is Nothing, "Text Here", Fields!a.Value)
If you need only part of the textbox then the easiest way is to use placeholders. These act almost the same way as a textbox but you can have several placeholders in a single cell/textbox each with it's own properties.
To add a placeholder click the cell/textbox first to get focus then right-click before or after any existing text/placeholders. Select Insert placeholder and set the expression as you wish, you can also format the placeholders font/color/decoration etc.
As an example I've got a small dataset with country names. If the country contains the word "Island" then I show different text and change the text decoration on one of the place holders. In the design you can see there are 3 placeholders, some text then a field then some more text.
When I run this I get the following output.
I've set strike thru on the countrydesc field placeholder but you can do the same on a text placeholder. You still have to do it in two parts, and expression to set the text value and an expression in the placeholders font properties to set LineThrough
You can set the condition on the Font/ TextDecoration on the selected report Item. There is an option for LineThrough.
For Example
=iif(reportitems!Textbox7.Value = "Cartons","LineThrough","Default")

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]

Way to add a calculated number of X's to a form input?

I have certain product codes with varying number of letters/digits e.g. 53HD6J, HH88WBD3 (varies between 5 to 10 letters/digits). In order for our barcode to scan these correctly there has to be 13 letters/digits. I don't want to make the user to input -XXXX after each code but rather have Access calculate the difference between 13 and the length of the code and fill the remaining with a X's. Is this possible either by vba or and expression?
I currently am using about 6 IIFs in one formula to fill remaining blanks with X's but hoping there is an easier way.
I have a form to enter in the batch number (product code). Once that form is submitted it links to a report that is printed. On the report are those batch numbers (53HD6J, HH88WBD3). The spot I want to have this feature is in a text box right next to the codes where Access determines the length of the codes and computes the remaining X's to add. This is in barcode font so this text box is where the 53HD6JXXXXXXX would go. Hope that clears it up!
So I have that part figured out. My problem now is my barcode font reads the text no matter what and translates it still so barcode shows up when the batch number is blank (I have four spots for batch codes to be inputted). So what I had before was =IIf([Text31]="",""&[Text31]&"","") which seemed to work. Hopefully I can continue this with the new formula. If that's unclear let me know.
**(The "" & & "" is so the barcode can be scanned).
My formula was wrong right above with the IIf. I figured it out! Forgot I had used ' Like "*" '. Thanks!
You can do what you want with String() and Left().
Here is an example from the Access Immediate window:
product_code = "53HD6J"
? product_code & String(13, "X")
53HD6JXXXXXXXXXXXXX
? Left(product_code & String(13, "X"), 13)
53HD6JXXXXXXX
Based on the update to your question, I think you can use that approach for the Control Source of a text box where you want to display the "expanded" product code.
Pretend your report has a text box named txtProduct_code where the raw product code, such as 53HD6J, is displayed. And there is a second text box where you want to display that value with the required number of X characters (53HD6JXXXXXXX).
Use this as the Control Source property of that second text box:
= Left([txtProduct_code] & String(13, "X"), 13)
Alternatively, you could make it a field expression in the report's Record Source query.
SELECT
product_code,
Left(product_code & String(13, "X"), 13) AS expanded_product_code
FROM YourTable;