SSRS - Get the ReportItem!____.Name of the current item (textbox or column) - reporting-services

I have a big report with 100+ columns named 'Column001', 'Column002' etc etc.
These columns hide depending on whether there is any data or not, and I'd like to have the last column have a right side border.
So I could do something like (in pseudocode)
= IIF(COUNT(ReportFields!Columns.Values) = CINT(RIGHT([CurrentReportItem].Name,3)), RIGHT_BORDER, NO_BORDER)
Is there any way to get the current item (ReportItem!) so that I can get it's name?

If you have control over the query then you can modify it to return the number of visible rows as a non-displayed new field in the result set and then compare that value at each column to decide if the border should be displayed.
If you do not have control over the query then I think you are limited to a painful series of nested IIf() statements.

Related

Can I use WHERE clause in an SSRS expression?

I saw the post on WHERE clause in SSRS expression. I am also trying to do a where clause, but in a different way. I need to show ItemDesc when ItemId = 4. I set a parameter so that it will always equal 4 for this cell. Now I just need the matching description field. I cannot hard code it because the description may change one day. Is there a way to associate the two fields?
=IIF(Parameters!ItemID_4.Value = 4, Fields!ItemDesc.Value,"")
I am converting from Crystal Reports to SSRS. This first image is the output from CR. I only need to show that ItemDesc in that top left cell.
This next image is from SSRS. It is not limiting the descriptions. It seems to be doing what my expression is saying. ItemID = 4, so display all ItemDesc values but the two fields are not associated right now. I need it to only show the matching value.
Thank you for your help.
I cannot hard code it because the description may change one day.
You are hard coding the parameter anyway by trying to do it that way. I don't think you need a parameter to achieve the result unless you are restricted from adjusting the dataset query.
If you are using an embedded SQL query for your dataset, I would just put a filter in WHERE clause: WHERE ItemID = 4
Another way if you can't adjust the query is to go to Report Data view > Right click on the dataset for your table, "Dataset Properties" > go to the "Filters" tab and add a filter with these settings: Expression = ItemID, Operator = "=", Value = "4" (or "#ItemID" if you want to keep your parameter).

Brining row where column valus is null

I have a store procedure which brings the data as shown below . I'm new to SSRS reporting, I would like to show only those row where "email" column is null. How can i achieve it in SSRS ? As i mentioned I'm very new to this , any screenshot will help me a lot. Thank you for your time.
For this problem, you'll want to change the row visibility to hide rows with a value in that column. I assume you're using a table or matrix to layout this data. You'll want to right click on the row where your data fields are entered. Specifically, the grey box at the left of the row.
From there, you'll need to select the option to Show or hide based on an expression.
And finally, you'll need to enter an expression that finds the values in the email field. I'm not exactly sure what the field names are called but something like the following expression should do it.
= Not IsNothing(Fields!EmailField.Value)
This will check the field where you get the email value with a built-in function of IsNothing. Additionally, since you want fields that do not contain values, the Not keyword reverses the results. If the function evaluates to true and a value is present, the row will be hidden and vice versa.

Dont's show rows in SSRS

I'm trying to achieve my report displaying a "No Data Available" message if no results are returned in my query.
I am trying to achieve this via an expression against the Row Visibility.
So I have a Tablix that looks like this -
If there is data available then I want the third, fourth and fifth line to show.
If no data exists then I want the first two rows to display.....
In the Row Visibility for the first two rows I have the following -
=iif(CountRows("RentTransactions") = 0, true, false)
In the Row Visibility for the remaining three rows I have the following -
=iif(CountRows("RentTransactions") > 0, true, false)
I have a filter on the Tablix that just limits it to "AccountType" = Water.
When I run the report between 01/06/2016 and 30/06/2016 - I know there are not transaction - so would expect my report to return the first two rows....
It doesn't it returns the bottom ones , with no data in it??
What am I doing wrong?
The DataSet is definitely called RentTransactions
There are a few issues going on here.
CountRows with the dataset name will always return the total number of rows in the entire dataset.
Row Visibility will make the entire row blank, but it will still take up space. This would look bad if there are alternating blank rows.
What you're really trying to do is control what is displayed in each cell. So in each cell you'll want to have an expression that checks whether or not to display a value. For example, for the Description field it would look something like this:
=IIf(Count(Fields!Transaction_Type.Value) > 0, Fields!Description.Value, "")
This expression will work by returning a count of 0 for NULL Transaction Types. You can customize this if needed.
Also make sure that the query is returning rows for dates with no transactions. Otherwise there's no raw data for the report to do anything with in the first place.

How can I append the results of additional queries to an SSRS report?

I am generating an SSRS report whose results are displayed like so:
I need to append similar query results (same exact query, one different parameter value) to the right of this data, so that one additional result set of data (from a 2nd query) would look something like this (but with different data, of course - this is just copied-and-pasted to show what's needed):
How can I add multiple of these similar-but-distinct result sets so that they can be read from left to right as shown above?
Solution: COLUMN GROUPING
If I have understood your question correctly, you are expecting to show those 3 columns repeatedly for different set of values. All you need to do is put those 3 columns in a group (Column Group) and Group by on whatever "Field/Parameter" you want to it repeat. Let me know how it goes!!
Based on what is written here, this is how I accomplished this:
I created a new report based on the existing one, and then added a Subreport and then dragged the existing (original) report onto it (I dragged "VariancePricebyProduct_Facelift.rdl" onto the subreport in "VariancePricebyProduct_Facelift_WithSubreports.rdl"). Then I selected the context menu item "Subreport Properties" and added a parameter ("Unit"), providing it with a "hard-coded/baked-in" value ("CHOPHOUSE") different from the one to be provided by the user for the main report.
Then, since I want to keep the same date values from the existing report, I added two more parameters to the subreport and set them to use the same values for the date range as those used there in the main report by selecting the "formula" ("fx") button and 2-clicking the appropriate parameter to be used as the passed-in (tramp) value:
That works. Just to make it plainer, here is how it looks at design time:
The mess at the top is "VariancePricebyProduct_Facelift.rdl"; the bit below is a Textbox/Label for the subreport and then the subreport itself.
And here is how the data looks where the original/base report finishes and the subreport begins:

How do i represent an unknown number of columns in SSRS?

I'm working on a rather complex report in Sql Server Reporting Services. My SP returns a dynamic number of columns each of which are dynamically named.
Basically think of a time keeping application. Each column that is dynamic represents a time bucket that time was charged to for that team. If no time was charged to that bucket for the period of time the report covers it doesn't show. Each bucket has its own identifier which i need to be the column headers.
I have an SP that returns this all. It does it by doing a bit of dynamic SQL with an exec statement (ugly i know but I'm on SQL 2000 so a PIVOT option wouldn't work)
I can have an indefinite number of buckets and any or all might show.
I found this - http://www.codeproject.com/KB/reporting-services/DynamicReport.aspx - which is helpful but in the example he has a finite number of columns and he just hides or shows them according to which ones have values. In my case i have a variable number of columns so somehow i need the report to add columns.
Any thoughts?
As long as you know a maximum number of columns, it's possible to do this after a fashion.
First, name the columns with a result from your query, so you can either pass it in to the query or derive it there. Second, just build out the report as if it had the maximum number of columns, and hide them if they are empty.
For example, I had to build a report that would report monthly sales numbers for up to a year, but the months weren't necessarily starting in January. I passed back the month name in one column, followed by the numbers for my report. On the .rdl, I built out 12 sets of columns, one for each possible month, and just used an expression to hide the column if it were empty. The result is the report appears to expand out to the number of columns needed.
Of course, it's not really dynamic in the sense that it can expand out as far as you need without knowing the upper bound.
This can be done. I did this and it works fine.
You don't have to know the maximum number of columns or show and hide columns in my approach. Use a matrix and modify your sp to return dynamic data to the structure mentioned in this blog post http://sonalimendis.blogspot.com/2011/07/dynamic-column-rdls.html
Build 2 related Datasets, first one for the report content, and the second one for the list of its column labels.
The Dataset of the report content must have a fixed number of columns and name. You can allocate some maximum number of columns.
In this example I have the first 2 columns as fixed, or always visible, and a maximum of 4 columns to be displayed by choice through a multivalued parameter, or depends on the query conditions. And as usual, we may have a total as well. So, it may look like this:
Fixed01, Fixed02, Dyna01, Dyna02, Dyna03, Dyna04, Total
The second Dataset with its values will look like this:
Name Label
---- -----
Dyna01 Label01
Dyna02 Label02
Dyna03 Label03
I have omitted the 4th Label to demonstrate that not all columns are being used by a certain query condition. Remember that both Datasets are meant to be related to the same query.
Now create a parameter named, say, #columns; populate its Available Values and Default Values with the second Dataset.
For each of those 4 dynamic columns, set the column visibility with the following expression:
=IIf(InStr(join(Parameters!columns.Value,","),"Dyna01"),false,true)
And for each of their column header Text Boxes, use the following expression:
=Lookup("Dyna01", Fields!Name.Value, Fields!Label.Value, "dsColumns")
As for the Total, here is the expression for its visibility:
= IIf(InStr(join(Parameters!columns.Value, ","), "Dyna01"), false, true)
AndAlso IIf(InStr(join(Parameters!columns.Value, ","), "Dyna02"), false, true)
AndAlso IIf(InStr(join(Parameters!columns.Value, ","), "Dyna03"), false, true)
AndAlso IIf(InStr(join(Parameters!columns.Value, ","), "Dyna04"), false, true)
And here is for its values:
= IIf(InStr(join(Parameters!columns.Value, ","), "Dyna01"), Fields!C01.Value, 0)
+ IIf(InStr(join(Parameters!columns.Value, ","), "Dyna02"), Fields!C02.Value, 0)
+ IIf(InStr(join(Parameters!columns.Value, ","), "Dyna03"), Fields!C03.Value, 0)
+ IIf(InStr(join(Parameters!columns.Value, ","), "Dyna04"), Fields!C04.Value, 0)
That's all, hope it helps.
Bonus, that second Dataset, dsColumns, can also hold other column attributes, such as: color, width, fonts, etc.
I think the best way to do it is add all the columns in your table and edit the visibility property of it with the help of arguments that you get from your SP..this will solve the purpose of dynamic column but when viewing the report you will get a lot of white-space which you can solve with SSRS - Keep a table the same width when hiding columns dynamically? and your report will be ready
I've had the need to do this in the past and the conclusion I came to is "you can't", however I'm not positive about that. If you find a solution, I'd love to hear about it.
An issue that comes to mind is that you need to define the report using the names of the columns that you're going to get back from the stored proc, and if you don't know those names or how many there are, how can you define the report?
The only idea I had on how to do this is to dynamically create the report definition (.rdl file) via C#, but at the time, I wasn't able to find an MS API for doing so, and I doubt one exists now. I found an open source one, but I didn't pursue that route.