hide ssrs textbox based on table data - sql-server

I can hide a table with no data by using this function in the visibility expression - =Iif(CountRows() > 0, false, true)
But I have a textbox used as a heading for the table.
How do I hide the textbox if the table relating to it has no data?
Thanks

=iif(countRows("DataSet2") > 0, false, true)
Where DataSet2 is the name of your dataset. This is because you are now informing the expression to Count the Rows in DataSet2. As no rows exist, it is set to hidden.
Further information...
Is the heading for the table adjacent to the table? Are you aware you can add rows above a table to provide extra heading information?
For example you can Right Click the Row Header, Select Insert Row -> Above and a new Row appears. You can then merge the cells horizontally, and set a title for the table (for example)
Now when you set the table to be hidden, this header row is also hidden automatically.
I'm not sure this is applicable to your situation, but I thought it might be useful to add, to reduce the complexity of your report, if you were unaware of the possibility

Related

Problem with Showing Query Results on a Form

I'm having a Projects lists Continuous form where the form's Record Source is based upon a table.
I have a requirement to display a field from another table which is linked back to original table using its primary key. The primary key is a AutoNumber field, but when displaying in the form I've used Input mask something like this "TMG/FEA/"0000.
So I made:
a unbound list box
and made the Row source as the query which displays the relevant information from second table
This query was created using primary key displayed in form (I mean the [Forms]![Form Name].[Field] ) as the where clause.
But the results returns blank. I'm Stuck here. I'm not sure if the query is not working due to the Input Mask or because of something else. Please help me. Thanks in advance
You should add to form field listbox, and set following values:
Data: primary key of your first table
After this, that field will duplicate ID value. Now you should transform RecordSource of this field in order to see contents from second table. So you should set:
SELECT [PrimaryForeignKeyID], [DetailedField] FROM tblSecond;. Actually I don't know the contents of your second table. Whereas PrimaryForeignKeyID is a field that links second table to first, so-called FK.
After this set following properties of list box:
ColumnCount = 2
ColumnWidth = 0;2
AllowEdits = False
Save form and open it for viewing.
In this case, your listbox will show the associated contents of second table on form.
So to my mind it is better for you to do such simple tables and forms, and you'll realize idea.

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.

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

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:

Make hidden table column take no space in SSRS 2008 R2

Has anyone figured out a good way to make a hidden table/matrix column take no horizontal space?
I could use some crazy conditionals to dynamically determine the contents of the columns (effectively sliding them leftward as far as possible), but that is nasty, plus doesn't allow for varying column widths in the columns to the right of the one I want to hide.
The idea is that when a parameter is set to "Any" then the column with the corresponding value should display. But when the parameter is set to an explicit single value the report doesn't need to contain that column any more (it will be separately listed as a condition at the top of the report).
This lets me use the same report in different situations, some requiring hiding unnecessary columns.
P.S. I think Microsoft should add expressions for object sizes, and I think they should add CanShrinkHorizontally to the CanShrink(Vertically) that already exists...
I think you are looking at the Hidden property of the column. Something that is hidden will still take up space. What you want to change is the Visibility of the column. Right click on the column header and click Column Visibility and set it there.
It looks like you can hide groups, and groups can be rows or columns.
Click the down-arrow next to "Column Groups" at the bottom of the Design pane, and turn on Advanced Mode. Modify the Hidden property of the Static group representing the desired column. Poof! You've made the entire column take up no space.
I struggled with this and came up with a workaround/solution.
In my scenario it was critical to have the RowGroups EffectiveDate, Description AND TransactionID. I wanted to hide the TransactionID column, because it was part of the grouping I couldn't set the Columns Visibility.
Before
After
So what I did was Merge Cells for the Description/TransactionID Header (and called it Transaction Type) and also for the first row of the tablix "Opening Balance".
Set the TransactionID textbox Hidden: True
The trick was to make the [DESCRIPTION] Right BorderStyle: None
Then set the Cell under [TRANSACTIONID] Top BorderStyle: Solid and Top BorderWidth 0.5
Alternatively make the fore color of the column you want to hide white and set border styles appropriately.

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