Change a label in a multiple value parameter in SSRS - sql-server

I'm trying to change a label under certain circumstances for a multi-value parameter. A stored procedure is the source for the values in the dataset that is used for the parameter. For example the parameter gets:
ID | NAME
-----------------
1 | Name 1
2 | Name 2
3 | Name 3
I'm mapping ID to the value and NAME to the label. I want "Name 2" to display as "Name Two" in the drop down but all others to keep the value fed in from the query. I can use an expression in the report like
=IIF(Parameters!PARAM.Label = "Name 2", "Name Two", Parameters!PARAM.Label)
but is there any way to do this same thing to the parameter label so it gets modified before being displayed? I know I could massage this in the query so it comes into the report as I want but I am hoping I can handle this in report builder.
I am using Report Builder 3.0 with SQL Server 2008 R2

I believe that the SSRS report renderer does not allow the parameter values to be determined via formula in properties. It probably has something to do with the order of when the form renders versus pulling the dataset.
Sorry for the bad news. It looks like you will have to accomplish this via the actual query feeding the parameter set.

Related

SSRS: filter parameter passed to sub-report

Let's say I have a dataset that looks like this:
ID | Name
1 | John
2 | Bill
3 | Mike (Inactive)
4 | Jim
I'm using that as a parameter in my main report, where the ID is the Value and Name is the Label. This works as wanted.
Now I have a subreport which is accessed by pressing a field on the main report. The field has an action set to go the the wanted subreport. At this moment, it is also passing all parameters.
This is what it looks like:
However, I want it to exclude all names that contain Inactive. I tried it by using expression such as
NOT(Parameters!pEmployee_List.Value LIKE "*Inactive*")
But when I pass to the subreport from the main, it gives the error that no parameter is selected.
Any ideas, suggestions?
EDIT:
After being pointed out by Stefan Steiger, I confused value en label. I would like the filter to work on value because it's being used a lot already on the subreport.
My second attempt:
=IIF(Parameters!pEmployee_List.Label LIKE "*Inactive*", "0", Parameters!pEmployee_List.Value)
The property "Value" searches in the ID, if you want to search in Name, you need to use the property "Label":
NOT(Parameters!pEmployee_List.Label LIKE "*Inactive*")

how to format the specified cell value in two different formats in SSRS Report

I have SSRS report data where we will have two different thing in some of the cells, For example:
Old Values in SourceDB
FirstName LastName
Robin Son
BOB Alice
Updating the DB values:
FirstName LastName
Robin S
BOB A
After some update, we will have the changes and new & old values in Audit Table so the report will be created like this.
FirstName LastName
Robin was: Son now: S
BOB Was: Allice now: A
Is it possible to have the Was value in Red color and the now value in Green Color.
In worst case if it is not possible how to make the whole cell value into red.
Thanks for the suggestions or answers or even feedback's are appreciated.
If you can't change your Audit table per Ashiko's very sensible recommendation to hold the Was and Now values in seperate columns, you will need to parse out the relevant parts of your string value in your report.
One way you can do this is through placeholders that have expression based values. In your SSRS table, add 4 placeholders to a table that is based on your Audit dataset, with the following expressions as their Label and Value:
Was: - ="Was: "
Old Value - =replace(left(Fields!LastName.Value,instr(Fields!LastName.Value," Now:")-1),"Was: ","")
Now: - ="Now: "
New Value - =mid(Fields!LastName.Value,instrrev(Fields!LastName.Value,":")+2,99999)
You can then format the individual placeholder items as you would normal text, with some one colour and others another.
If you do this correctly, you should end up with something like this:
Design View:
Rendered:
Do be aware though, that if you do resort to splitting your string values in this manner, if that pattern you are searching for (eg: Now: in the old value or : in your new value) you will get undesirable results in your report.
If this is an entirely internal report for monitoring purposes, this is probably not an issue. If this will be customer facing however, I strongly recommend that you add additional columns to your Audit table for the Old and New value to allow you absolute control.
Did you try this?
Select the cell
Click F4 to open cell properties or right click the properties
In font tab , Select Color
4 Select Underneath Expression
5 Write as
=iif(Fields!ColumnName.Value = "WAS","Red","Green")

Is there any approach to get access the Sub report variable or to get SubReport element in main report?

I am writing an SSRS report in which I've a tablix that actually contain a subreport in one of its table cell. Now I want to understand to get this value as Sum on main report. For example, below is the student data:
Student Name | Total Subject | Obtained Marks (Sub Report)
XYZ | 6 | 35
ABC | 6 | 46
In above example, I am able to see the total marks of the first subject only. But I need to get the total form all 6 subjects from sub report. My tablix is already has Grouped by Student Name.
Below are the ways I tried to get it done:
Added another column in tablix and try to get the subreport as ReportItems! Subreport2, didn't work.
In the same column, I tried with Sum (Subreport2).
But since Subreport2 as report items are not accessible I'm not able to get it done.
UPDATE 1
I am using below expression to get sub-report value:
=ReportItems("Subreport2").value
The short answer is, no, you can't access fields from a subreport in the manner that you are attempting to. However, there is an easy way to get the values from that subreport that you may not have realized. The basic solution is to simply add another dataset to your report using the same query or stored procedure that is used in the subreport and getting the required data from that dataset. For example, you could then use a lookup function to match the data as needed. The lookup function requires four parameters detailed in the following expression.
= Lookup([SourceValue].Value, [DestinationValue].Value, [LookupValue].Value, "[DestinationDataset]")
The idea in your case would be to put your student name or ID field from the main report dataset in for source value, match that value in your subreport dataset for the destination value, get the value you need for lookup value, and the subreport dataset goes in parenthesis to indicate where to get the data from. So the following expression gives you an idea of what you need.
= Lookup(Fields!studentID.Value, Fields!studentIDSub.Value, Fields!ObtainedMarks.Value, "SubreportDataset")
Take a look at the documentation if you need any addition information.

SSRS Subreport Inside a Table Cell not Retrieving Parameters Properly?

I have an SSRS Report using a Table.
You can select multiple Clients and Periods and for every pair there will be a row in the table. So 2 Clients * 3 Periods = 6 rows.
Now... there are some cells that are more complicated than having a single value and I want to place a subreport inside these cells. The Subreport will take the Client and Period for that particular Row as params.
This is where the issue comes in. The Parameters will not pass properly.
I can put Parameters!ClientID.Value(0) as an expression for example and it will pass the first ClientID properly but if I just put Parameters!ClientID.Value it breaks... And I want the Client/Period for the current row.
But how is it that I can't pass the params but CAN fill a new dataset for every row based on that Client/Period pair??
Note that I'd really prefer not to have to edit the SP that builds that dataset to return the Client/Period itself. Sure that would work.. but WHY would that be needed when I have the Parameters?
Any ideas? I'm doing this in a Visual Studio Report Project.
If I've understood correctly you don't need to use the parameter. You need to use the value of the field from the dataset. So if your table shows client and period then the parameter values passed in would be =Fields!Client.Value and =Fields!Period.Value
Client Period SubReportCell
Bob 2017 "subreport here passing in Bob, 2017"
Geoff 2015 "sub report here passing in Geoff, 2015"
You should just be able to choose these from the dropdown lists in the subreport setting dialogue box.

Birt report : How to hide in's and out of the table value in Birt Report

I have a following employee table value as below :
name | cost
john | 1000
john | -1000
john | 5000
when we add the cost column total will be 5000.
I need to print only the 3rd row in BIRT report, since the 1st and 2nd row get cancelled out each other.
I'm stuck at filtering the table for above scenario.
Couldn't you just solve this using SQL like
select name, sum(cost)
from employee
group by name
order by name
?
Or do you just want to exclude two rows if they have exactly the same cost, but with different signs? Note that this is actually something different, take for example the three rows [ john|1, john|2, john|-3 ]? In this case, a pure SQL solution can be achieved using the SQL analytic functions (at least if you are using Oracle).
Elaborate your question. Its not clear if these are columns or rows.
If These are columns:
Create a computed column in your dataset
In Expression builder of that column add/sub values using dataSetRow['col1'] and dataSetRow['col2']
Add only that computed column to your table.
If these are rows
Select rows you don't want to print
Go to properties tab
Find Visibility property and click on it
Check Hide Element option

Resources