Microsoft SSRS: How to make horizontal flowing fill-in text - reporting-services

Apologies if this has been asked before, I did look around but I'm new to SSRS and I might not know the right keywords to find what I'm looking for.
I am trying to make a new report with a couple of sentences like:
The purpose of this report is to determine an academic plan for student __________, by listing all the courses they will take.
I would like this to display in my report "just like" a paragraph of text, except that I would like the blank filled in with the student's name.
I understand how to do "basic" textboxes and how to bind values to them.
But how to I get a textbox that knows to expand horizontally until it reaches the end of the line, and then continues on the next line? If this was HTML (with some binding libraries like Knockout), I'd stick it all in a <p>, like:
<p>The purpose... <span data-bind="studentName" />, by listing ... </p>

You need to use placeholders, they will do exactly what you want.
Create a text box with the full sentence, then at the position where you want the student name to appear, right-click on the actual text and choose 'create placeholder'.
Once the placeholder is visible, right-click and choose properties, then just set the value to whatever you want.
The placeholder is like an inline textbox, you can set it to be the contents of a field or an expression, give it it's own formatting etc...

If you need a field in a text box with static text, you'd put the text in quotes and use the & to combine them
="The purpose of this report is to determine an academic plan for student " & Fields!NAME.Value & " by listing all the courses they will take."
Text boxes don't expand horizontally though. The text will take up as much room in the text box as it can and then will make a new line in the text box - expanding vertically.

Hoping you are using BI Studio to do this.
I am assuming that your underlying query just produces one value called FieldName and your data source is called DataSource. The text will wrap to your textbox but you can add in a vbCrLf if you want to force linebreak. Concatenating strings you can use + or &.
In your textbox make a formula and set it to:
="First part of string "+First(Fields!FieldName.value, "DataSource")+" rest of sentence"+vbCrLf+"more string"

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)

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]

How do I insert a dataset value to a BIRT report outside of a table / cube?

okay, this has got to be simple - but I can't seem to find an answer...
I am creating a summary report (using BIRT 2.6.1), and laying out a few specific summary values in a grid (not a table or a cube).
Say it's a simple query:
SELECT decision FROM dataTable
I created a data binding / aggregation (named "sumDecision") on my grid, of a type count, where my expression is:
dataSetRow["decision"]
Now, I've tried to insert this into a grid, either as "data" or "dynamic text" with the column binding:
row["sumDecision"]
But when I run the report, it comes up blank. How would I do this? Using dataSet["decision"] doesn't seem to do anything either.
I would create a Text Item (not Dynamic Text, just Text) and use the "Value Of" tags on the text item. This will give you an expression editor and as long as your grid is bound to the data set in question, you will be able to choose your data element there.
Since you just want to see the text in the grid, make sure and choose "HTML" for the format of the text item.
One solution is to create a table of 1 column, 1 detail - then delete the detail & header rows, and create my grid inside the footer of the table.
From here, I can add a dataset to the table, and create aggregations that work to my hearts content.
Is this the right way to do this, or am I missing something?

How do I best display CheckBoxes in SQL Server Reporting Services?

One of the many quirks of Reporting Services we've run across is the complete and utter lack of a CheckBox control or even something remotely similar.
We have a form that should appear automatically filled out based on information pulled from a database. We have several bit datatype fields. Printing out "True" or "False" just looks silly, as this is supposed to look like a form that has been auto-filled out, so we want to have a series of checkboxes and labels that are either checked or unchecked.
We are running SSRS 2005 but I'm not aware of SSRS 2008 having added a CheckBox control. Even if it did, we'd need to have an alternative for the time being. The best we've found so far is:
use Wingdings
use images
use text boxes with borders and print a blank/space or a capital X
All three approaches require IIF expression shenanigans.
The Wingdings approach seemed to work acceptably, and was the most aesthetically pleasing except that for whatever reason it didn't always print correctly. More importantly, PDF exports, also for whatever reason, converted all fonts (generally) to Arial and so we got funky letters instead of the Windings dingbats.
Images, being a pixel-based raster, don't do so well when printed along side vector stuff like text. Unless handled carefully, they tend to stretch, pixelate, and do other unprofessional looking things.
While these methods do work (some with limitations as mentioned above) none of them are particularly elegant.
Are we missing something obvious? Not so obvious? Does someone at Microsoft have a good reason why such a control was not provided in SSRS 2000, let alone 2 versions and 8 years later? This can't be the first time this issue has come up...
I, along with others in my shop, have used images, toggling the hidden attribute based on the field value (true or false). We haven't had any problems with blurring or scaling, unless we tried to increase the scale of the image beyond 100% obviously.
Another option I've used is similar to the wingdings idea, but I just use a plain old "X". On our forms at least, it is not uncommon for someone to use an X in a box instead of a check mark, so it looks completely acceptable. Plus, you don't have to worry about strange characters when printing.
As for why Microsoft does not include a checkbox control, I can't answer that as I've been wondering the same thing myself for a long time now.
I just wanna share the idea on this blog. SSRS: How to Display Checkbox on Report
First create a textbox
Then change the font family to Wingdings
Insert an expression on the textbox and write this expressions.
=IIF(Fields!Active.Value,chr(254),"o")
Fields!Active.Value could be anything from your query that should return a boolean value 1 or 0.
Then click Preview and see the checkbox ;)
More styles can be selected on the blog that I shared above.
Here is an example of my output
What I have used to display a check box (or ballot box):
1- create textbox (that will become your check box)
2- change font to Arial Unicode MS
3- in the expression window use:
ChrW(&H2611) for a filled-in checkbox
ChrW(&H2610) for an empty checkbox
Besides the different methods already presented, as of SQL Server 2008 R2 there's a built-in control that can be used for checkbox-alike functionality: the Indicator!
Have a look here for details on how to use it: https://web.archive.org/web/20190916105459/http://blog.hoegaerden.be/2012/08/04/displaying-checkboxes-in-an-ssrs-report/
To be able to use a field of type bit, you'll have to cast it to int first. This can be done either in the dataset query or by adding a calculated field to the dataset.
If you want the NULLs to come up as yellow, then you'll need to build the expression that way so it takes that requirement into account as well.
Here's a possible expression for a calculated field:
=Switch(
IsNothing(Fields!YourBoolean.Value), 50,
Fields!YourBoolean.Value = False, 0,
Fields!YourBoolean.Value = True, 100)
Depending on the meaning of your fields - is False good or bad - you may need to swap the zero and 100.
Another way to do thisd is go to "Placeholder properties" of TextBox and check Html - Interpret HTML tag as styles
Then in the Value - Expression put this line of code for checked:
="<font face=""Wingdings 2"" color=""green"">" & Chr(81) &"</font>" & "some other text"
Or this code sample for unchecked:
="<font face=""Wingdings 2"" color=""red"">" & Chr(163) &"</font>" & "some other text"
This way you can have checkbox and text in the same textbox.
Later edit:
If you are having problem displaying Wingdings 2 on Azure, then use Wingdings.
Apparently it works.
="<font face=""Wingdings"" color=""green"">" & Chr(253) &"</font>" & "some other text"
Or this code sample for unchecked:
="<font face=""Wingdings"" color=""red"">" & Chr(168) &"</font>" & "some other text"
You can also use a string calculated field like "[X]" or "[ ]". It's less pretty than the textbox with border but you don't have to put a specific control for the value and you can fill table or matrix with this.
At least there is some solution for the checkbox. I'm still looking for full justification for my text (In fact I'm looking for another solution than SSRS know).
ACCESS 97 could make this kind of thing but not SQL SERVER 2012.
I think there is a bug with SSRS and embedding font characters above 128 (some thing todo with ANSI encoding). Basically you can use 1-128 fine, the rest show up as tall rectangular blocks.
I like NY's idea of the textbox with a border and an optional X - this sounds simple and effective.
This is building on Dragos Durlut's answer. I don't have a high enough reputation to comment but I can answer...
I needed a checkbox as part of text that is passed as a parameter. The parameter contains HTML and is used in a placeholder set up just like Dragos suggests: HTML - Interpret HTML tags as styles.
Instead of having to switch between the HTML and the strings, you can use the HTML Escape Codes (& + # + CharCode + ; --> ¨)
="<font face='Wingdings'>¨</font> Empty checkbox"
Since mine is a parameter, it just pass in the string:
<font face='Wingdings'>¨</font> Empty checkbox
If you need the checkbox selected, you would pass in either ý or þ instead:
<font face='Wingdings'>ý</font> filled with an x
<font face='Wingdings'>þ</font> filled with a checkmark