如果所有行都为空,则隐藏列

时间:2021-12-07 08:21:00

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.

我在SSRS 2008中有一个Tablix,我有一个有时有数据的列,有时却没有。如果NO行没有数据,我想隐藏列。

So this would hide Column 2:

所以这会隐藏第2列:

Column 1     Column 2     Column 3     Column 4
1                            3            4
2                            3            4

This would NOT hide Column 2:

这不会隐藏第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?

在SSRS 2008中有没有办法做到这一点?

Thanks!

谢谢!

6 个解决方案

#1


1  

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.

我怀疑你必须要有创造力。例如,运行查询以获取列的非空行数。然后将计数结果用作列的visibility属性上的表达式的一部分。即如果数大于零......显示。

This might help

这可能有所帮助

Reporting Services - hide table column based upon report parameter

Reporting Services - 根据报告参数隐藏表列

#2


6  

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.

很老的帖子,但是当我使用SSAS多维数据集时,我想出了一个更好的解决方案。由于所有聚合都已在SSAS中发生,因此您只需检查层次结构的父级别是否具有值。

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.

SSRS没有总结或必要的声明。因为函数的计算结果为true或false,并且因为表达式正在评估是否隐藏列(即True隐藏它),这是公式中所需的全部内容。

#3


5  

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.

如果您的字段包含值而不是数字,则以下内容应该可以隐藏列中每行只有NULL值的列。

Place this code as an expression in the Column Visbility object for each column that you want to evaluate

将此代码作为表达式放在要评估的每个列的Column Visbility对象中

=IIF(Count(Fields!<NAMEofCOLUMN>.Value) = Cint(0), True, False)

#4


1  

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)

#5


0  

You can explore column visibilty property of a tablix based on expression: If its nothing then evaluate the condition to just Nothing.

您可以根据表达式探索Tablix的列visibilty属性:如果没有任何内容,则将条件评估为Nothing。

Follow the link:

点击链接:

SSRS 2008 Column Visibility Expression Evaluates to true, column not visible

SSRS 2008列可见性表达式求值为true,列不可见

#6


0  

Select all Columns in the Tablix and set Visibility - Hidden properties as:

选择Tablix中的所有列并将可见性 - 隐藏属性设置为:

=IIF(Fields!ColumnSample.Value = Nothing, True, False)

#1


1  

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.

我怀疑你必须要有创造力。例如,运行查询以获取列的非空行数。然后将计数结果用作列的visibility属性上的表达式的一部分。即如果数大于零......显示。

This might help

这可能有所帮助

Reporting Services - hide table column based upon report parameter

Reporting Services - 根据报告参数隐藏表列

#2


6  

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.

很老的帖子,但是当我使用SSAS多维数据集时,我想出了一个更好的解决方案。由于所有聚合都已在SSAS中发生,因此您只需检查层次结构的父级别是否具有值。

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.

SSRS没有总结或必要的声明。因为函数的计算结果为true或false,并且因为表达式正在评估是否隐藏列(即True隐藏它),这是公式中所需的全部内容。

#3


5  

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.

如果您的字段包含值而不是数字,则以下内容应该可以隐藏列中每行只有NULL值的列。

Place this code as an expression in the Column Visbility object for each column that you want to evaluate

将此代码作为表达式放在要评估的每个列的Column Visbility对象中

=IIF(Count(Fields!<NAMEofCOLUMN>.Value) = Cint(0), True, False)

#4


1  

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)

#5


0  

You can explore column visibilty property of a tablix based on expression: If its nothing then evaluate the condition to just Nothing.

您可以根据表达式探索Tablix的列visibilty属性:如果没有任何内容,则将条件评估为Nothing。

Follow the link:

点击链接:

SSRS 2008 Column Visibility Expression Evaluates to true, column not visible

SSRS 2008列可见性表达式求值为true,列不可见

#6


0  

Select all Columns in the Tablix and set Visibility - Hidden properties as:

选择Tablix中的所有列并将可见性 - 隐藏属性设置为:

=IIF(Fields!ColumnSample.Value = Nothing, True, False)