Hiding Textbox in SSRS and freeing up space - reporting-services

I am designing a report using SSRS 2008 R2 where there can be 2-3 sub headers. Now the headers are passed as parameters showing different options such as date range etc.Now I have used three TextBoxes for the three headers but the problem is if I pass 2 headers and even if the third TextBox is hidden it takes up space. I would have used a tablix had the headers appeared in a body section but It seems I cannot use a tablix in the header section.
I hope I was able to make myself clear. Does anyone have any answers regarding this.
Thanks.

If I may make a suggestion, that I've used before, use placeholders. So, what you do is go into the box that is right before the optional text box. Then, right click. You should see an option at the bottom for Create Placeholder. Click that and it will ask you to create an expression. Do an IIF check on your variable.
Example: IIF(MyVar = 1, vbcrlf + "My Header", "")
What this will do is check to see if MyVar = 1. If it does, then it appends onto your text box a new line with the text "My Header". Otherwise, it will take up no space.
Please let me know if this helps and good luck with your project.

You have to 'play' with 3 properties of your TextBoxes.
CanGrow: True
CanShrink: True
Hidden: =IIf(Parameters!YourParameter.Value = "", True, False)
To save space, you can also set a minimum Height for your TextBoxes and put them attached to each other.

you have to change the visiblity:
1)select textbox
2)right click on text box.
3) go to Text Box Properties
4)visiblity tab>click on "fx" for expression and write following code.
use if condition:
=IIF(Cstr(Header.value))="",TRUE,FALSE)
i hope it will solve ur issue.

Related

SSRS expression based on visibility of a textbox or column

Is it possible to inspect the visibility (Collapsed/Expanded) of a textbox in SSRS and use this in an expression?
For example :
=iif(Fields!column1 Is Visible,"Use this label","Use this other label")
What I want to accomplish to have the initial value of a column header display some text, when user clicks a particular value the details row are displayed (this is a Tablix), and then the header would change to something else (E.g. initial report state is to hide detail rows and only show Tablix member totals so column displays "... total", when user expands to view details column header changes to "... number".
In MS Access through VBA I could inspect the visible property and create code based on this. Till now haven't found a similar way of doing this in SSRS 2016.
Tried setting expressions for visibility as well as setting expressions for changing value of a textbox.
=IIF(Fields!accountnum.Value IS NOTHING OR Fields!accountnum.Value = TRUE,"Station #", "Station Count")
No error messages. My results should be to change header (textbox) value based on whether detail rows are collapsed (hidden) or expanded (visible).
To answer your first question:
Well of course this is possible, just not they way you want to do it. Here is a smimple example. Lets say your visibilty criteria is the following expression:
'Visibility expression
=IIF(Fields!Category.Value = "Visible", False, True)
Now you dont check on the visibilty with the Is Visible criteria, you just use the same expression again. Like this:
=IIF(
IIF(Fields!Category.Value = "Visible",
Fale,
True) = True,
"This one is not visible",
"This one is visible")
To answer you problem:
They way you want to do it, it is not possible. But you can do this with a workaround.
Add a user defined parameter to your report with two options:
Display details
Hide details
Then add two tablixes to your report. One tablix without the details and one tablix with the details you want to show.
Then go to the first tablix Tablix Properties > Visibility and add the following expression:
=IIF(Parameters!VisibilityParameter.Value = "Display details", True, False)
And the expression for the other tablix visibility:
=IIF(Parameters!VisibilityParameter.Value = "Hide details", True, False)
Now based on the parameter result the talbix with or without the details will be displayed.
You can do this, maybe it won't look too elegant but I'll show you what I did and you can see if it's useful.
Note: Using this method, you can't change the actual column header directly as it's out of scope so this may not meet requirements but you may be able to adapt it. I just thought it was a nice challenge ! :)
First I got some sample data (WideWorldImports sample database) that just gave me a CountryID, CountryName and Continent.
Once you have your data, add a table, drag CountryName into the first column and remove the remaining two columns.
Then right-click the Details row group and do Add Group => Parent Group Choose Continent as the Group By field and check the Add Group Header option.
The table design should look like this, nice and simple.
Next we will set the toggle on the detail rows. Right-Click the "Details" row group and chose "Group Properties". On visibility, click 'Hide' and check the "Display Can be toggled by the report item" to Continent.
We should now have a report that expands and collapses as expected.
Next vertically expand the 'blank cell' just above the countryname as we'll need a bit of room to work with. Make it about 4 times the normal height, we'll change it back later so the size is not important.
In the blank cell, right-click and do Insert => Rectangle.
In this rectangle, right-click and do Insert => TextBox. Double click the text box and type your "collapsed state" column header caption. In my example I just used "Collapsed Header".
Repeat and add another textbox (It must be within the rectangle again). Set this text box to your "expanded state" caption. In this example I just used "Expanded Header".
Next, right click the "Collapsed header" textbox, then properties then set the visibility to Show and the toggle item to Continent.
Repeat for your "Expanded Header" but this time set visibilty to Hide, like this..
Finally, position both text boxes at location 0,0 so they overlap and shrink the cell back down to it's original size.
The final design will look something like this...
When we first run the report we see this.
If we expand a node, we get this.
I do not think this is possible in SSRS. You could change column header text depending on your condition, For Ex: IF (A) then Header A else Header B. But you wish to change Column Header based on some clicks (expand / collapse) on report and this is not possible. I mean we need some data to set condition not clicks.
But maybe someone with more Experience on SSRS would throw some more insight.
This is what InScope() is for. See here for more information

How to remove Page Header White Space in SSRS report for pages 2..x

We are trying to remove the white space taken up by the Page Header on every subsequent page after page 1. We don't have blank pages, just white space taken up by the header. It also doesn't seem to matter whether we send it directly to the printer or export it to a PDF.
On the Report section, we have set ConsumeContainerWhitespace = True.
On the Page Header section, we have PrintOnFirstPage = True
and PrintOnLastPage = False. Too bad there's not a
PrintOnlyOnFirstPage option!
We have two Rectangles on the Page Header section encompassing all of our header fields, and we've tried setting the Hidden property of these
rectangles to be:
IIF(Globals!PageNumber = 1, False,True).
We have several Text Box fields on the Page Header inside both rectangles. We are turning the visibility attribute of these Text Box fields either on/off depending on whether there's data present in the accompanying data field, e.g. =IIF(Len(First(Fields!SpecialOrderId.Value, "PurchPurchaseOrdersDS")) = 0, True, False).
I've tried the suggestion about putting the header code in the body and programmatically hiding it, but I'm getting this error:
\SSRS Reports\Reports\PurchPurchaseOrder : error AX3026: : PageNumber is invalid. InvalidIdentifier
THECODE:
Public Function PageNumber() As String
Return Me.Report.Globals!PageNumber
End Function
CALLING IT:
=IIF(Code.PageNumber() = "1", False,True)
Thanking you in advance.
Folks, I found a link on a webpage that said: "VB code is no more supported in AX2012-SSRS". Obviously this is why the PageNumber() function does not work for us. However, using Harry's suggestion of moving our header fields into the body of the report fixed our issue and we no longer have two inches of blank white space on pages 2..x! Thanks!

How would you dynamically hide or display a SSRS header based on a parameter?

I need to hide or display the header of a SSRS report based on the value of a parameter. The parameter is called "Show Header?", and the values of this parameter are true and false. Is there a hide property for headers? If so, I'm not able to find it.
I'm not sure if you are talking about the table Headers or the report header (some people seem to use the term interchangeably).
I'm still self learning SSRS so there may be better options out there but a quick test i found the following.
For a Boolean Parameter type:
I used the logic below to hide the visibility based on parameter (you may want to play around with the true/false order depending on your parameter to get it to work how you want):
=IIF(Parameters!ShowHeader.Value, False,True)
Table Headers:
Just highlight the text boxes you want to show/hide and open up the properties, under Visibility select "Show or Hide Based on Expression"
(NB. i found highlighting the full row would only let you select the full tablix properties not the single row so I just shift clicked all the cells and pasted the IIF statement into the "Hidden" Property for the selection in the properties window)
Report Headers:
I am not sure you can hide the Header (couldn't see any immediate hiding properties or options), however you could hide the contents of the header using the same sort of process (right click properties and alter the Visibility setting or add the code into the Hidden property). In testing I found that the header would reduce to remove white space when items where hidden so may work out for you.
The sneaky way I've found to get around the limitation of SSRS on this is to put my "header" in the first row of the first tablix and just hiding the actual report header, which you probably know cannot be deleted. That way, I can show or hide the first row of the tablix by whatever criteria I desire. This method works well for me.

SSRS-Handling different headers based on page number

Here is the similar imageI'm trying to create an SSRS report using SSRS 2008 R2.
I have a requirement to show different headers in different pages based on page number. For example, I need two textboxes to be shown in all the pages except page-1. So I put them in a rectangle inside report header and set the visibility(expression) based on pagenumber.
This works fine but it leaves a lot of white space in the first page header as it is hidden. How can I get rid of the whitespaces?
I tried putting those 2 textboxes out of the header, but I'm unable to hide them based on pagenumber, as the pagenumber global variable can be accessed only in header and footer but not from the body.
Is there any other approach to hide these textboxes on first page and show on all other pages?
Thanks in advance.
Update: added similar image
You can't recover the space in the header but you can not use it in the first place and let the text box grow when necessary. The bad part is that when it is exported to Excel, all the text will be in one cell.
Since your text is different sizes, you'll need to use HTML formatting.
In your regular header, add the page formula you are using with the TRUE part containing the text needed for your additional info and the FALSE part with an empty string - "". Use the <br> tag for a page break and the <font> tag to set the size.
="<b>This is My Page Header</b>" & IIF(Globals!PageNumber > 1, "<br><font size = '2'>Text Box 1" & "<br>" & "TextBox 2" & "<font>", "")
You'll need to set the Placeholder properties to Interpret HTML tags.

Force SSRS 2005 to print a new page

I have a field on the footer that may contain more text the the textbox would support. If it does, I need the report to print another page, even if it's completely empty, containing only the footer field.
Basically, if a condition is true, I want the report to print a new page, displaying my footer in it, even if there's nothing else to be printed.
How can I achieve this, preferably with field expressions?
And if you have a solution that's not a field expression (external code for example), could you also point me to the basics of it?
On any block you have the property PageBreak, you can choose begin, end or none. By choosing end, a page break will be insered after the block.
=iif(Globals!PageNumber Mod 2,True,False) this helped me to show (visibility) a text box on even pages only from my footer