Iterate over columns of a report to dynamically show/hide them? - loops

I want to try and implement a parameter which will allow users to dynamically choose which columns are going to be shown in a report. An idea is to create a multiple value parameter which has column names. After user hit View Report I want to try iterate over columns and selected values to join visibility.
How I can iterate over columns inside a tablix?
How I can iterate over multiple values of a parameter, so I can find if some value is selected or not?
I am using MS SQL Reporting Services 2012.

For a table, i.e. fixed columns, you can use the following approach. It's not really loop based so much as an individual distinct visibility check for each column based on a parameter selection.
Set up a multi-valued parameter that lists the columns that can be displayed/hidden.
Then, for each of these columns in the actual table, set the Column Visibility to use an expression based on the parameter:
The expression would something like:
=IIf(InStr(Join(Parameters!IncludedColumn.Value, ","), "Col1") > 0, false, true)
What this is doing is constructing a string of all selected values for the IncludedColumn parameter, then checking if a certain column identifier is included; Col1 for this particular column. You'd use different constants for each column.
So when running the report this approach can hide/display columns based on a parameter selection.
All columns selected:
Some columns selected:

Related

Add rank for each row group as a new column in SSRS

In SSRS I am trying to add a rank as a new column and ranking should be based of "New Deals(#)" field. Also ranking should start from 1 for every Region. Please see the screen shot for reference. I don't want the ranking to be done on stored Procedure, so could someone suggest me a way to have a rank on SSRS based off of a filed inside a row group.
Design View
Use an expression in the field
=RowNumber("Your Region Group Name Here")
That will generate a new row number sequence for each region. The number assigned will be based on the sort order of the group.
Of course you would not be able to use this row number to order your data.
Incidentally, the best way to do this would be in the stored procedure. That way it becomes part of your data, allowing you to sort the region by another field (name perhaps) without changing the rankings assigned.

Bind tablix with a single row of out of many rows returned by dataset in SSRS 2008?

I am fully aware that ideally, dataset should return only relevant rows with which to bind tablix.
However, in this particular case, I am utilizing same dataset to bind multiple tables and need to perform some filtering 'on the fly'.
I tried writing logic in column visibility of each cell to achieve desired output but there is no unique condition available on cell level .
I need to bind only single row from the dataset based on my unique column value, any pointers will be highly appreciated, thanks !
Although you haven't provided any code/data samples but may be you can utilize row visibility property to filter rows from dataset with which to bind individual tables as suggested here

Using extended properties (attributes) to columns in an SQL table for defining how data should be input later on

I have never used SQL. I would like to create a table with different columns. Then I would like to create a program which allows the user to insert entries. For each token of the entry, I would like to retrieve from an attribute of the corresponding column the way this particular part of the data entry should be entered. For example, I will have some data retrieved automatically (e.g. the date and time), some for which I will propose the user to insert the last added value, and some for which I will ask the user to explicitly type the value.
I do not know if "Attribute" is the right term; the attributes that I have available for each column at the moment are "Name", "DataType" and "Description"
I want that my program dynamically adapts to the table columns and to the property of each column, especially because I will have several tables to be filled. So my program would check the table columns with their properties, and interact with the user for the creation of a new entry.
Is there a possibility to add attributes to a column?
Otherwise I will have to encode the information I need for my program in the "Description" field (aka "MS_Description").
I googled terms like "sql add column attribute", but I could only find results concerning how to add a column to a table.

OBIEE Characteristic Table with dynamic header

I have original data as shown above with a single record. I have name of the field in one column and value in another column. I need to transform make the heading dynamic as shown below.
I tried with table pivot table and trellis, not no success.
You should be able to do this in a pivot table in OBIEE.
Please see my below screenshot. I was able to get my column originally named 'Total Contracted Cases' to now be called 'USD' because that is the value in the column 'Currency Code'. So for you, you should be able to get the column 'PARAM_VAL1' to be called 'COUNTRY' because that is the value in the column 'PARAM_CD1'. See below for my example:
In the second image, be sure to click on the 'Measure Lables' properties to hide the value.
For columns that are not metrics (no aggregation rule set) that will be used in the 'Measures' section of the pivot table, you will have to define an aggregation rule in the column properties dialog box to keep the value from being converted to null. If your data is as you say it is (a single record), then this should not be an issue; you should be able to pick any aggregation rule and not have to worry about dropping data.

Values not showing in Access form combo box

I have an application in Access 2003 that I am working on. In it, I have an employee table, which is connected to two other tables. The two connected tables are tables that hold a few fixed KeyWords. In my main employee table, I just have the ID from the other table, rather than having the whole word.
I wanted to make a form for entering data into these tables, so I made a query from the three tables that shows the all the regular fields of the employee table except instead of those two ID's, I showed the words themselves.
I then made the form and set the query as the RecordSource. The fields that have keywords are Combo boxes on my form, and their ControlSource is the keyword field from the query (like I mentioned earlier, the value can only be one keyword out of a list). Now, the problem I face is this: When I want to see a single record, it shows the correct value in the ComboBox, but when dropdown the menu, it doesnt show any of the other values.
What is the best way to do this? Am I doing this in the wrong way?
Thank you
I'd approach this slightly differently, set the combo box Row Sources to include both the id and text fields (you can hide the ID column if required by setting it's width to zero). Now add the ID fields to the employee query; you shouldn't need to join the other tables to the Employee table in this query, these fields are foreign keys and the combo boxes should show the text for you automatically. Set the form Record Source to this query, now set the combo box Control Source to the appropriate ID value from the form Record Source.
If you let the wizard build a form for you based on the Employee table you will see this approach in action.
ControlSource is the column name of the table where any user entry will be saved.
RowSource is where you type the name of the saved query or manual query typed directly into that field, which is used to provide a list of available drop down options for the combo box.
RowSourceType should be set to Table/Query, which is based on aforementioned RowSource method.
Now to correct the problem of only displaying what you begin to type (i.e. "Allow AutoCorrect" in Property Sheet > Other) or already have saved for that record without other options appearing after clicking the drop down is the following:
In Design View, click the combobox in question.
Property Sheet > Format > Column Count = set the desired number of columns to display in drop down.
Property Sheet > Format > Column Widths = set the desired width of column in the drop down.
Property Sheet > Format > List Width = set the desired width of the drop down itself.
Property Sheet > Data > Bound Column = set to the column of query table (i.e. 1 for ID and 2 for list options, if you only have two entries)
Note: If your desired drop down options are column two and not column one (makes things easier btw) then do the following change from above:
Property Sheet > Format > Column Count = set the desired number of columns to two.
Property Sheet > Format > Column Widths = add two entries 0",1" which means the ID field is not visible (0") and the options field is one-inch.
The easiest way to sort this out in the beginning is to view the column header names to know what you are looking at in the meantime by doing the following:
Property Sheet > Format > Column Heads = set to yes. At least you will know what is showing and whether or not you are on the right track.
I had this same issue in access 2016 and the issue was with my datatype. The combo box didnt accept 'Longtext' so i just changed datatype to 'shorttext' instead and all the values appeared.
You have set the query as the recordsource for the form. A form only shows (and ties to) ONE record at a time.
Since you want the combo box to show all the values, you should set the RecordSource of the ComboBox to your query.

Resources