Unable to hide a field on an SSRS report - sql-server

I've written a report on SSRS which has an initial parameter that you select from. That then shows a specific set of records from a SQL database. However, dependent on that selection I want some of the fields to show or not show in the report.
The fields are listed as Row Groups
and I've gone into the Group Properties/Visibility and written the following under "show or hide based on an expression":
=IIf(Parameters!StoreType.Value = "xxxxx",true,false)
My impression was that would hide the column if what I specified was true and display it if it was false, however it's not working, it still shows that column associated with that "Group". I tried altering to "Fields" rather than "Parameters", but that has no effect either.
There are quite a few fields I would like to apply this to, but obviously I need to get one working before I roll it out to all the rest. If anyone can shed light on what I've done incorrectly/need to do differently that would be much appreciated.
Cheers,
Chris

Put your expression on column visibility instead.
Right click the cell on top of column Store Group then select Column visibility.

You need to set the Column Visibility instead of Row.

Related

SSRS - Can Individual Columns in a Grouped Row be Hidden Without Hiding the Entire Row?

I am using SSRS 2014, aka Report Builder 3, to develop reports at work. The one I'm currently working on requires a "user-level view" and a "supervisor-level view". The difference between the views is that non-supervisory users don't need to see the first three columns and should only see data related to themselves, not other users. Supervisors do need to see everything, but also want to be able to limit what's on-screen at any given time.
I can read the user's role and set visibility based on that. The problem is that I can't hide the columns because the option is not available for them. The option IS available for the columns I'm not grouping on, so I assume that this is because the rows are being grouped on those first three columns. Is there a way around this?
As far as I know there is no nice way of doing this. You can actually hide columns that are not on the details rowgroup even though the right-click context menu does not show the option.
If you left click on the column head to select the entire row, then use the properties panel you can set the Hidden property to an expression.
In fact, what you are actually doing is setting all the textbox's hidden properties.
Unfortunately this literally just hides the textboxes so it just leaves a blank area. This might not be too bad if its at the start or end column but if it was in the middle there would be a gap.
In my sample report with the column not hidden
and then with it hidden
Sometimes you just have to rethink how you present the data. In my example, for instance, I could move the data I want to hide (Year) to the next column across but still in the same row group, then delete the first column. Like this...
Now when I run the report with everything visible it looks like this.
Now, I set the ROW visibility of the row with the [Year] field and when I run the report I get this...

SQL Report Builder: How to merge groups?

I have two reports, one I created and another I'm using as kind of a guide/template. In the template report, the column grouping appears to be "merged", but that's probably not the right term for this scenario (hence my trouble in Googling this further). Here is what my template looks like:
TEMPLATE
However, mine looks a little different. I have both my year and month grouping, but if I merge them (by selecting both cells and click Merge inside the Layout section), I lose the "month" group. Here's how mine looks:
MINE
So how do I mimic the style of the template? I see that the two groups in my template both have parentheses around them, whereas in mine, the parentheses only exist for my child group. Is that my problem? What does this signify?
For further clarity, here's essentially what I'm trying to get the output to look like (column for 8/2019, column for 9/2019, etc.)
VERSUS
What I have (column for year, sub-column for month)
I was prepared to tell you that you must've gotten a warning message before your group disappeared. But to my surprise, the group disappears just like you said it would.
Instead of merging the fields, follow these steps:
Select the row that contains the year textbox.
Right-click, and select "delete rows"
When prompted, mark "Delete rows only".
Enter the textbox that has '[month]'
Place your cursor after '[month]'.
Type in a "/".
Without leaving focus from inside the box, right-click and select "Create Placeholder".
In the properties box, set the value to Fields!year.Value.
As for the parentheses around the group names. Seems that it may have to do with the fact that the group isn't represented in a particular way in the structure. You can read here to learn a little more. But the report always works as I expect with or without them so I don't pay them much attention.

SQL Server Report Builder for Shipping Labels, One per page

I am trying to replace our outdated shipping label program with a SQL Server report, and I am very green when it comes to doing this. I am testing using an ODBC connection with some sample data. I have created a DataSource which is a simple "SELECT * FROM LABELLIST" statement. Each row in this table contains ONE label.
In the DataSet I have each column that is needed (To, From, Carrier, PO, etc) listed. I have dragged the fields onto a blank report and in the expression it is set to "=Fields!FROMADDRESS.Value". As mentioned earlier, each ROW is a new label, but when previewing, I only get the first record as a label. What do I have to use (tablix, matrix, list, grouping?) to accomplish this and how?. I'm not sure how to search for this answer online and was hoping to get a reference page to read on how to do it. Everything I've found pertaining to labels or "row to page mapping" is showing how to print multiple labels/rows to one page and not each row to a single page.
EdIt: to clarify, each label is being sent to a zebra thermal printer and follows a similar format to a UPS or FedEx shipping label. Each row in the table will be one shipping label.
The key for you to understand is how SSRS handles Page Breaks. I have a similar answer here.
Whatever formatting you have for your labels should be placed inside a Rectangle.
Place this rectangle into a table with one cell that is grouped by label ID.
Set the group to page break between instances.
This makes the report repeat one instance of the label on each page. It can be a little tricky to understand at first, but it is a very useful trick. I have used this for reports like invoices where we needed one on each page.

SSRS Error - "Report item expressions can only refer to fields within the current dataset scope or, if inside an aggregate

I'm new to SSRS and I'm not sure if it will do what I would like to do.
I'm getting the following error in SSRS:
"The Value expression for the text box 'Textbox17' refers to the field 'DayCnt'. Report item expressions can only refer to fields withing the current dataset scope or, if inside an aggregate, the specified dataset scope. Letters in the names of fields must use the correct case."
I have a list that's 3 rows and 3 columns. I need to use multiple data sets across the rows and columns. I would like everything on the report to be grouped on the school ID, which each dataset does have.
I will be using multiple datasets per cell in some cases and I'm using a textbox and then dragging the dataset field into it. I'm not sure if grouping is the problem. I'm not sure how to group the entire list at once, or if it is row based, or how the grouping works with a list with multiple columns.
How can I get everything in the list to be based off of the school ID?
You can reference more than one dataset in the same data region (table, etc.) but only if it makes sense to use aggregate functions on all the datasets except the primary one that your grouping is based on. I'm not sure if this makes sense for your use case or not.
An aggregate function is something like First. If you don't specify the dataset, it defaults to the "current dataset." The current dataset is an invisible default that you can't see or set anywhere in the UI, as far as I can tell.
=First(Fields!MyField.Value)
vs.
=First(Fields!MyField.Value, "MyDataset")
Now, there are a couple of tricky things to know about the Report Builder UI.
When you drag a field into your report, the expression it creates does not specify the dataset.
When you drag a field into your report, it changes the current dataset!
This leads to exasperating behavior such as the following:
Create a data region.
Set its grouping to a field from Dataset1.
Drag in a field from Dataset1.
Run the report. It works!
Drag in a field from Dataset2. RB will automatically use an aggregate function, as you would expect.
Run the report again. Now you get an error, not on either of your fields, but on the grouping of your data region.
The problem is that dragging in the field from Dataset2 changed the current dataset to Dataset2 and broke everything that uses Dataset1 without explicitly specifying it. The solution is hacky:
Manually change the expressions of all your fields from Dataset2 so they explicitly reference the dataset, or
Reset the current dataset by dragging in a field from Dataset1 and deleting it.
You cannot use different datasets on only one SSRS table. One table should only refer to one dataset.
And the solution to your question is: recreate your dataset (query), try to get one dataset by using distributed query if they are on different server instance, or specify database name when they are on the same server.
You might have done some modification on the Dataset and you did not refreshed the fields.

In SQL Server Reporting Services, how do I display the hidden columns when printing or downloading as a file (csv, pdf etc)

I have a situation where I need to hide columns of the report when viewing but when printing or downloading as a file, those hidden columns need to be displayed. Hiding the columns is not an issue, its just that I cannot figure a way to display the hidden columns when printing/downloading.
I do not want to create 2 separate reports for this.
Thanks
What I do in these situations is to create a parameter for the report that says something to the effect of "Display Hidden Columns?" or "Show Printable View?" and then wire up the Visibility property of the column to that parameter. Yes, they might have to run the report again, but it keeps you from having to do a separate report yourself.
Select the column and On the 'Column Visibility' option, select 'Show or hide based on an expression' and select fx formula-expression button.
The group heading will say "Set expression for: Hidden"; write the expression =Globals!RenderFormat.IsInteractive OR select from UI under "Build-in Fields".
There is no in-built functionality to hide columns only when viewing the report in the browser. Reporting Services renders the report the same way, whether you then save or print the report is of no consequence.
The only way to achieve what you want is to either:
create a new report
(as mentioned by Dave) provide a
parameter that controls hiding the
columns
Regardless when you actually generate the report for print/save it will look identical on screen

Resources