开发者

How to draw line after every group in SQL Server Reporting Services?

Below is the report I have created. I would like to draw a line after every group a开发者_StackOverflow社区s depicted with red line in the image.

Tried meddling with Textbox Properties > Border Style expression. But that would not stay once I close and reopen it.

If I set border for whole group, the line would repeat for every row in group which I dont want.

Any help?

How to draw line after every group in SQL Server Reporting Services?


  1. Click on the View tab in Microsoft SQL Server Report Builder.
  2. Ensure the Properties check box is checked so that the Properties window is shown.
  3. For the ProductionCountry select the entire group row. The properties should show for the row.
  4. In the properties dig down to Border->BorderStyle->Top. The value will more than likely be blank.
  5. In the Top field, enter the expression below for the top border.

Top field value:

=IIF(Fields!ProductionCountry.Value = Previous(Fields!ProductionCountry.Value) OR Fields!ProductionCountry.Value = First(Fields!ProductionCountry.Value, "mydataset"),"None","Solid")

Change mydataset value above to match the dataset name of your report.

Note:

If current row belongs to the same group as the previous row OR current group row is the first of the dataset, set border to none, set border to solid.


Select the entire detail row and add this expression to the BorderStyle-Top property:

=IIF((Previous(Fields!ProductionCountry.Value) <> Fields!ProductionCountry.Value) 
    OR (Previous(Fields!IndustryName.Value) <> Fields!IndustryName.Value) 
    OR (Previous(Fields!ProductGroup.Value) <> Fields!ProductGroup.Value), 
    "Solid",
    "None")


To improve on @niktrs's answer, I would suggest:

=Iif(Fields!ProductionCountry.Value = Previous(Fields!ProductionCountry.Value) OR IsNothing(Previous(Fields!ProductionCountry.Value)),"None","Solid")


This has the advantage of not adding a line on the initial group row, even when the first group displayed isn't the first group in the dataset, for example where sorting or filtering is in place.


What I found really easy to do is define the top border for the group. In this way each new group adds a border between the last row of the previous group and the first one of the new group. It also adds a border after the headers.

This solution does not draw a border at the end of the last row. If you need that border too, you can define the bottom border for the tablix that contains the groups.


=Iif(Fields!ProductionCountry.Value ="","None","Solid")

also change the border default none left solid right solid bottom none top the above expression. and to the rectangle properties change bootom order..

i tried like this for the top border and it was working fine...


In my case I have an aggregate value so I cant use previous function so I hard coded the first value from the group which I knew that is going to be the first value in that group.Then in Border Style I used this expression

Top =iif(Fields!Group_Name.Value="Hard Corded(first value)","Solid","None")

Also in Border Color used this expression

=iif(Fields!Group_Name.Value="Hard Corded(first value)",,"Black","LightGrey")
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜