Breaking the SSRS report depending on the Multi Value Parameter - sql

I am working on a SSRS report with a Multi Value Parameter which contains list of names. I have written an expression for the title that works like "Result for SELECTED NAME". It also have an option of (Select All) which displays all the results with title as "Result for MULTIPLE NAME". It is working fine up to this part.
Now I have to modify the report like, If i select multiple values, the report should break into pages with each selected name on different page with title for that individual parameter value(name) as "Result for SELECTED NAME".
Please help me. Thank you.

You can place the entirety of your current report (excluding headers/footers) into a List object. I assume youa re returning the selected values from the parameter (like Manager Name) as part of your DataSet. Assuming this is the case
Create a new list
Insert the contents of your report into the rectangle of this List
Right click the List Row Header and Select Row Group -> Group Properties
Set the Group to Group on
=Fields!ManagerName.Value
This approach will take a simple table like this
And break it into a list like this
Then you can just set the Tablix Properties of the List to Add a Page Break After to checked
Hopefully this is helpful. If you have further questions on this then please let me know

I worked on it and found a way to make it happen. I first created the row group for Names. Then applied the page break for each instance option. Then deleted that group column (Only deleted column but not group). Then added that group in a static column on the top, and wrote an expressions to show that group itself as a title using concatenation.
But here I faced another problem, when there is no data for the selected name, the title row isn't displayed in the preview as it also a column in the table.

Related

How to group a text row in multiple data rows in Microsoft Report Builder

Basically I'd like to from this :
What I have
To this :
What I Want
Case in Orange are data that I pick up with an sql request while "This e-learning phase..." is just a plain text.
Does anybody knows how to do that ?
You could add a Parent Row Group and Group by the Information field.
Unfortunately, this would place the Information on the Left side of the table. Fortunately, there is a Layout Direction property for the table that can be switched from LTR to RTL so that the table is created from Right to Left instead of the default Left to Right.
This way the grouped information field on the right would only have one cell while there may be multiple Activities.
I'm not sure you'll be able to do this exactly how you want. This is because you cannot add rowgroup columns after non-grouped columns.
The only way you could get close is to not show the text if it's not the first row in the dataset (or rowgroup if the report is grouped somewhere)
You could use something like this in the Value expression.
=IIF(
ROWNUMBER("myDataSet_Namehere") =1,
"This e-learning phase must be completed before the start of the classroom part indicated below.",
Nothing
)
You could use a similar check to then set the vertical alignment property.
It looks like this...
The other option would be to move the test to the top of the table on it's own row in above the column headers, it would probably look neater..
Or you can wait for somebody else to come up with a better solution :)

Show a name instead of an id

I currently have these options set in a combo box:
This box will show the projectIDs that a current company has which is set with the criteria. I just want to show the name of the project as people will not know just by the id. If I remove the check box for the projectID it will just remove that field completly and not show anything. I have debugged what companyBox.Value is and it is indeed a number for a company and if taken this id and replaced it with the following query which is built from the picture and it returns the results I want. I just cant get the values to show in the combo box.
SELECT projects.projectName
FROM companys INNER JOIN projects ON companys.companyID = projects.companyID
WHERE (((companys.companyID)=7));
Gives me all the projectNames where the companyID is 7
And as seen below that same query just gives me blank spaces instead of the names:
Ok, if you have say a query, then as noted, then you can use a "join" to pull in the other table (based on that "projectID").
So, for a general report etc., then your approach of using the query you have is correct.
HOWEVER!!!
For a combo box? They have this feature and ability built in. In other words you do NOT in general need a join.
The combo box has two parts:
A sql query that "drives" or "fills" the combo box. This can (and will be) of course based on the Projects table.
VERY important:
Our combo box is to save, store, put, use the project ID into a column in our CURRENT form. That form of course is based on a differnt table (the forms current table). So, keep in mind the two concpets:
Combo box can be driven by any table to display data.
Combo box will/can use a column from that "other" table to SAVE into a current column on the current form.
Now of course the Project "id" is the VALUE we want, but we sure as don't want to display that "project id" value, since as you note, humans want the nice looking text.
First Rule:
ALWAYS, but ALWAYS make sure the FIRST column of the combo box "sql query" is the column we WANT to save into the current form, but ALSO the column we are going to HIDE AND NOT show to the user.
So, a combo box can with great ease HIDE the first column. You can hide other columns, but as a general rule a VERY HIGH number of my combo boxs will have two columns. So, you might need company "id", but would want to display company name as nice text to the user, but store/save/use the "id" of company for this purpose.
So, in your case? Change the order of your columns.
You want:
ProjectID, ProjectName, and you ALSO can continue to have a filter based on company.
So, once you get above setup, and you WILL NOT need a sql join. Remember, the combo box has it own "whole sql statement" based on table projects.
So, the combo box will:
Save/store/use the ProjectID when you select a project.
And it will display the project name, but behind the scenes it will use + save ProjectID.
So, just make sure that you set the length of the first column in the combo box to 0 (to hide that projectID from display).
Next, make sure you set WHICH column value from the query the combo box is to save.
That column will be the FIRST column, so you want to set that to 1
Your combo settings will look something like this:
In above, the CONTROL source is your CURRENT form and table.
So, I want to get a Hotel "ID" from the table hotels, but I am going to save the results of the combo box selection INTO a column called Hotel_ID
And note VERY careful - I set the bound column = 1 (that is the FIRST value from the query that drives the combo box.
Next up:
We want to hide the first column value, so you need this setting in format tab of the property sheet for the combo box:
NOTE VERY close in above. I set the FIRST column width = 0. this is HOW you hide the "ID" of hotels - I only want the user to see the nice hotel name. (or in your case Project name).
But, the 2nd column, I have a width for the Hotel name (or in your case project name).
So, make your first column in the query for the combo box the "id" of project id. Set the width of the first column = 0.
So, the query that drives the combo box? It is based on the ONE table, but you need to ensure that the "id" that you going to use is the first column, and simple hide it from display.
So, a combo box has a sql query that drives the combo box, and that query in most cases will NOT be the current table.
So, you have to set BOTH settings (the column the combo sql query will use - but to avoid confusing, then just adopt the habit of making the 1st column the "id" or value you want from that sql.
But, after setting above, you STILL have to set what column to shove/put that column into on the current form. (that setting is the control source).
In effect, a combo box is a kind of look-up into the other table, and it can display nice user friendly text columns, but still use + store the ID.
So, your query should look more like this:
SELECT ID, projectName
FROM projects
WHERE (((companys.companyID)=7));
I don't know if your first column of Projects table is "ID" (or is it ProjectID), but as you can see, the combo box ONLY needs to be based on the one table, and with our new rule - we always use the first column of the query the "id" value we want.
Now, of course the above is "hard coded" for company, and your original query that drives the combo box was fine - just that the order of the columns display was incorrect.

SSRS SQL report builder deleting column

I have a problem with SSRS report builder. Basically what I want to do is to delete a column. I have a report that someone else made and there is 1 column (xxx) that no longer exists in data source tables so I need to delete it.
When I go to query designer and delete this column from the code and run it there, it works. I close query designer window and see that list of columns (fields) is updated now and xxx column is not there. Then, I delete this column manually in designer (default screen) and when I try to run the report, It doesn't work:
"The Value expression for the text box ‘XXXDataField’ refers to the field ‘xxx’. Report item expressions can only refer to fields within the current dataset scope or, if inside an aggregate, the specified dataset scope. Letters in the names of fields must use the correct case."
But that field should be already deleted. So I don't know what else I can do, or what it can be linked to. I just want to delete it. Any Idea?
Thank you
If your dataset does not contain xxx but your DataTable has this error is normal
You either delete that column from your table or at lease delete DataSet Binding from table so that SSRS does not try to retrieve that column from DataSet
It will be a reference to the field in another field. For example, if you deleted a column that showed an OrderShipped status, then you might have another text box highlighted based on this.
The error is telling you which textbox is in error. So, click somewhere on the designer, then in the properties window, right at the top, click the dropdown which allows you to choose specific report items, choose XXXDataField (the one named in the error message) and then check the value expression. In there you will find the reference to the column you deleted.

MS Access: Conditional formatting - highlight duplicates

Is there an expression that I can use in MS Access ,to highlight Duplicate entries in Reports?
I tried something like Expression is : Count(*)>1 but it doesn't work.
Br,
I suspect that the original query will need to be bulked up with a sub-query that has an ID column and count of ID. The outermost query will then need to also return the ID count.
Within the report you'd then need add another field that would show the linked ID count if it was > 1.
Access reporting (and forms) allows conditional formatting to be used in a similar way to excel.
See Ribbon: Report Design Tools>Formt>ControlFormatting...
It will let you change the format of a control depending on the value it, or another control, contains.
It's a very nice feature and will also let you add bar charts to you list forms to graphically represent the values sorted in a control.
However, the data set will need to have a column that indicates whether the current row has duplicate records. The snippet from you current query that you provided (that I repeat below) will not do this:
...OR (((Object.Key) In (SELECT [Key] FROM [Object] As Tmp GROUP BY [Key] HAVING Count(*)>1 )));
Without seeing the whole query I can't really help much, but you will need to remove the use of IN and make the SELECT statement a subquery of the main SQL Statement. The main query resultset will need to be LEFT JOINED to the sub query using the Key field. Because of the LEFT JOIN you can use "isnull(Key)" in the SELECT clause and isnull(Key) will be true for non-duplicate rows.
You can then refer to thiscolumn in your conditional formatting
I hope this makes some sense.
You
For a quick and dirty way to highlight duplicate data:
Select the object you want to highlight if it's duplicated, and make
the background white (or whatever the colour of your background is).
Create a copy of the object that you want highlighted if it's
a duplicate.
Format the copy so it has a highlight, and/or add extra text
(eg: DUPLICATE)
Put the copy behind the original (so it can't be seen).
On the original object, select "Hide duplicates" in properties.
Ensure "Hide duplicates" is NOT selected on the copy.
So when the duplicate appears, Access will hide it, but then the object you've created that was originally hidden beneath now becomes visible - effectively highlighting the field.
(Unfortunately it will only highlight the field itself, not the entire section.)

Reporting Services - hide table column based upon report parameter

I have a report in Reporting Services 2005, and I want to hide or show a single table column based upon a report parameter. Does anyone have any idea how to do that?
Thanks!
Use the visibility property of the column. This worked for me.
=iif(Parameters!ParameterName.Value = "TextValueOfTheParameter",False,True)
Set the Visibility for the column to an expression which will return true or false. This property can be found on in the Visibility tab on a TextBox for example.
Click the radio option for Expression and then your expression might look like
=Parameters!ShowColumn.Value
Tip: If the expression returns "False" then the column or row will be visible. If the expression returns "True", the expression will be hidden. This tricked me at first.
Let’s say my report(SSRS 2005) have 5 columns. And I want to show/ hide columns based on a parameter(multi select with all 5 column names) selected by user. do as following
1)Create a parameter of type string (ColumnVisibility is name of my parameter) with desired column names in labels for the 5 columns and INT number(01,02,03,04,05) respectively in the values in “Available Values” section of the parameter wizard.
2) Then Go to column Properties on design . Go to “visibility” and paste following
=iif(instr(Join(Parameters!ColumnVisibility.Value,","),"01")>0,false,true)
3) repeat same for all the columns, by increasing the int value by 1..see following for example
2nd column
=iif(instr(Join(Parameters!ColumnVisibility.Value,","),"**02**")>0,false,true)
3rd column
=iif(instr(Join(Parameters!ColumnVisibility.Value,","),"**03**")>0,false,true)
And so on. For SSRS 2008, when you right click on the column you can see "Column Visibility" option. paste the code in "show or hide based on an expression" section for each column.
For some of my reports I've set the Visibility (Specifically the Hidden property) for the column to:
=IsNothing(Fields!Site.Value)
Note that this only works if the relevant field can be null in the underlying dataset, otherwise you will see the blank column.
If you want to hide whole column, when there are no data at all for that specific column in the report, you can use following code in the column visibility/expression:
=IIF(IsNothing (Sum(Fields!columnA.Value, "ReportA")),False,True)
when I do as above, I can make the column disappear but it leaves a gap in my table. Is this the expected result. I was hoping the columns would also shift over. I'm trying to hind a column for one group and then display it for the next group.
To make a null column disappear,
Right-Click column to select Column Visibility, then Set expression for Hidden:
IIF(IsNothing(Fields!FieldName.Value),True,False)