Hide Column if all Rows are empty - sql-server-2008

I have a a Tablix in SSRS 2008 and I have a Column that sometimes has data and sometimes doesn't. I want to hide the column if NO rows have data.
So this would hide Column 2:
Column 1 Column 2 Column 3 Column 4
1 3 4
2 3 4
This would NOT hide Column 2:
Column 1 Column 2 Column 3 Column 4
1 3 4
2 2 3 4
Is there a way to do this in SSRS 2008?
Thanks!

Very old post, but I figured out a better solution for this when using an SSAS cube. Since all of the aggregation has already occurred within SSAS, you can simply check if the parent level of the hierarchy has a value.
This is done accordingly:
=IsNothing(Fields!Field.Value)
No summation or if statements necessary with SSRS. Because the function evaluates to true or false, and because the expression is evaluating whether or not to hide the column (i.e. True hides it) that is all you need in the formula.

If you have fields that contain values and not numbers then the following should work to hide columns that have only NULL values for each row in the column.
Place this code as an expression in the Column Visbility object for each column that you want to evaluate
=IIF(Count(Fields!<NAMEofCOLUMN>.Value) = Cint(0), True, False)

In design,
Go to the column, right click and select 'Column Visibility`
Select show or hide based on expression and give the expression as:
=iif(Fields!column_name.Value=Nothing,True,False)

I suspect you'll have to get inventive. For example run a query to get a count of non empty rows for the column. Then use the count result as part of an expression on the visibility property of the column. I.e. If count greater than zero... show.
This might help
Reporting Services - hide table column based upon report parameter

Select all Columns in the Tablix and set Visibility - Hidden properties as:
=IIF(Fields!ColumnSample.Value = Nothing, True, False)

You can explore column visibilty property of a tablix based on expression:
If its nothing then evaluate the condition to just Nothing.
Follow the link:
SSRS 2008 Column Visibility Expression Evaluates to true, column not visible

Related

What is the expression to hide a column in an SSRS report if the current month number > an integer?

I am trying to hide a column on my ssrs report based on a condition that the current month aka month(today()) is a specific integer.
For example, I have to hide "column11" until November 1st and "column12" until December 1st.
Thank you.
Have in mind hiding some columns could result in duplicate values into your report, especially if those columns are the ones making unique your rows.
Now for your specific case you can use:
=IIf(
(Month(Today()) >= 2 AND Day(Today()) >=5)
AND
(Month(Today()) <= 3 AND Day(Today()) <=4)
,true,false)
In ssrs when you right click column you will find column visibility option.
There you can write expression for hiding I.e if true it will hide column, if false then will
Show column.
Expression will be something like below.
IIF(Month(today())<11,true,false)
And for December it will be
IIF(Month(today())<12,true,false)
Note: this is pseudo code and may have typo error

Limit rows to show with Boolean parameter in SSRS

I have a coulmn and it has 2 different sets of data, one which starts with Letter and followed by number(Ex:A8753426) and another is only Numeric(7655477)
I have created a report and it shows all the rows. I want it to show all rows when end user select to Show with Letters else it should only shows Numeric values.
Column
A2232322
24343432
12234455
Z1234544
I am using SSRS 2008 to create reports
created 2 reports and linked them with the action field so when they want to see Alpha-Numeric values they just need to click on link and it takes them to that report
try: in datasets filters
use expression like
=iif(isnumeric(left(Fields!yourfield.Value,1)) = 1 ,"number","letter")
operator: "="
Value: would be your parameter (should have 2 available values "number" and "letter")

ssrs expression sum doesn't sum all column

I have a column like:
LEFT_PIN_HEIGHT_MIN
0
0
0
1
1
0
I wrote it to Tablix as below,
=Sum(Fields!LEFT_PIN_HEIGHT_MIN.Value)
I want to sum the fields and result must be "2" but it doesn't sum the column
and writes all the rows to Tablix.
I agree with the previous answer that your first choice ought to be to calculate this in the SQL, but sometimes that is not as practical.
Are you trying to display the column's sum in each row? If so, add the dataset name as a second parameter in the sum function, as in
=Sum(Fields!LEFT_PIN_HEIGHT_MIN.Value,"Dataset1")
Replace "Dataset1" with the name of your dataset. The Sum function you're currently using is defining the sum within the context of each row in your tablix. Adding the second parameter changes that context to return the sum for the entire dataset in each row.
If your tablix is large, this may result in a performance hit, since the expression will evaluate each time it is displayed, hence the preference toward doing it in your dataset query.
I suggest to do It with SQL. Use query to SELECT SUM(LEFT_PIN_HEIGHT_MIN)...
If you want to achieve It by SSRS expression you can do It in following:
Right Click on table1_Details_Group > Group Properties...
In Group on: field provide LEFT_PIN_HEIGHT_MIN click OK
To hide 0 > Right Click on left side of values row > Row Visibility check Show or hide based on an expression then write following expression: =IIF(Fields!LEFT_PIN_HEIGHT_MIN.Value = 0, true, false) click OK
It should work.

Applying different Visibility to each Tablix

I have a report showing hours and dollars that are written off. Jobs for this report are classified as NRB (non-billable) and non-NRB (billable). Each job type has its own Tablix in the report and I want to populate each Tablix based on a bit value - IsNRB.
All of the "0" IsNRB rows should populate the top Tablix and the "1" values should populate the bottom Tablix . For the most part this is working. What is happening, however, is that some Programs or Clients will have both NRB and non-NRB jobs, and it appears that as each Tablix works its way through the rows of the report dataset, it will capture and retain the first value for IsNRB and apply that to the entire report.
I have tried logic similar to the following in a number of places/ways:
=IIF(Fields!IsNRB.Value = False, Fields!CustProgram.Value, NOTHING)
The Grouping hierarchy of the report looks like this:
ProgramGroup
ClientGroup
Job/SubJobGroup
Detail is here
I have tried setting evaluative expressions similar to the one above on TablixVisibility, GroupVisibility, RowVisibility, and in the field expression itself. The behavior seems consistent in that the first row for that Program, Client, or Job sets the value of IsNRB for the entire report.
As a concrete example, the first Program, "Cascadia" has three rows where IsNRB = 1/True and two where IsNRB = 0/False, and the latter two rows of data are always misapplied because the value of 1/True is overriding the 0/False valued rows.
What is the proper approach to take that will allow the first Tablix to accept and display rows of data where IsNRB = 0 and the second Tablix to show those with a value of 1? Do I need to abandon the IsNRB bit datatype and just have a distinct dataset for each Tablix? That seems like a klunky way to approach the report.
Filter each table on the IsNRB field. Right click the tablix and select Tablix Properties. Select filter, then then select the field you want to filter against (IsNRB) and the value your want it to be (1).
This will put all records with a 1 for the field in one table, and with a 0 in the other

SSRS 2005 - How do I find the value of a cell 1 column over and 2 rows up?

I am trying to find the value of a cell 1 column over and 2 rows up using something like excels offset
You can get the value of a cell if the cell has a name using the following
ReportItems!YourCellValueGoesHere.Value
You can't: there is no column or row collection as such to use.
In addition, matrix controls, grouping, and merged cells would further complicate this