【问题标题】:SSRS Alternating Row Colour Within GroupsSSRS 在组内交替行颜色
【发布时间】:2014-06-03 09:09:42
【问题描述】:

我有一个带有行分组的 ssrs 表报告,我想知道如何在不更改组列本身背景颜色的情况下更改组中行的颜色。有了我找到并实现的答案,当我想要第一个表的效果时,我得到了图片中第二个表的效果:

任何帮助将不胜感激。

这是实际报告的图片,它正在分组:

【问题讨论】:

  • 看起来你刚刚弄错了 rownumber 函数的范围。行组的名称是什么?你用什么表达式来设置背景颜色?
  • 从您的示例中也不清楚每个新组是否都以白行开头,还是您希望它与上一组中的最后一个相反?
  • 如果每个组都以白行开头,那很好,但如果可以与上一组中的最后一个相反,那将是首选。我使用的一些表达式来自其他链接,例如:IIf(RowNumber("TheNameOfYourGroup") Mod 2 = 0, "White", "WhiteSmoke") And: = IIf(RowNumber(Nothing) Mod 2 = 0, "Silver ", "Transparent") 还有一些我发现的 vb 函数
  • 奇怪,TBH 我不确定为什么这些对你不起作用。我无法重现这个。报告的结构是什么?
  • 这是一个普通的表格报表,有两组,一组是不可见的,另一组是可见的区域

标签: sql reporting-services


【解决方案1】:

RowNumber 技术仅适用于详细信息组,即最低级别的组(未定义组列)。将其视为返回数据集中的行。

相反,我会编写一个表达式来计算与 RowNumber 等效的值,但用于组级别 - 通常在组键字段上使用 RunningValue ... CountDistinct,如下所示:

= Iif ( RunningValue ( Fields!tableid.Value , CountDistinct , "TheNameOfYourGroup") Mod 2 = 0, "White", "WhiteSmoke")

【讨论】:

  • 这对我有用,但我必须将 CountDistinct 更改为 Count。
  • 将 CountDistinct 更改为 Count 对我也有帮助。谢谢凯文。
【解决方案2】:

我需要将交替应用于所有行,包括总行数:

'define Report Variables: ActiveRowColour, ColourA, ColourB
'Call this function in one cell per row by setting => BackgroundColor=Code.NewActiveRowColour(Variables!ActiveRowColour.Value)
'Then All other cells on that row set -> BackgroundColor=Variables!ActiveRowColour.Value
Public Function NewActiveRowColour(ByVal sActiveRowColour As String) As String
	If sActiveRowColour = Report.Variables!ColourA.Value Then
		Report.Variables!ActiveRowColour.Value = Report.Variables!ColourB.Value
		Return Report.Variables!ColourB.Value
	Else
		Report.Variables!ActiveRowColour.Value = Report.Variables!ColourA.Value
		Return Report.Variables!ColourA.Value
	End If
End Function

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-17
    • 2015-07-30
    相关资源
    最近更新 更多