"All" Parameter Value Blog
<p><strong>Question:</strong><br />How can I get a green-bar effect (alternating colors) in a matrix?</p> <p><strong>Answer:</strong><br />For a green-bar table, you can simply use a background color expression like this: <font face="Courier New" size="2">=iif(RowNumber(Nothing) Mod 2,"Green","White")</font><br />However, there is currently no GroupNumber() function on which to base a green-bar calculation in a matrix.<br />GroupNumber can be (mostly) simulated by using the RunningValue function to get a running distinct count of group expression values.<br />However, the trickiest part of green-bar in a matrix is the fact that some matrix cells may contain no data at all. This makes the group number calculation incorrect for empty cells.<br />To work around this, you need to effectively calculate the group number in the row header and then use that value inside the data cells.</p> <p><strong>Step 1:</strong> Add a (fake) inner row grouping<br />Select the innermost row grouping in your matrix. Right-click and select Insert Group.<br />For the group expression, group on a constant, such as <font face="Courier New" size="2">=1</font></p> <p><strong>Step 2:</strong> Calculate the name of the color in the inner row grouping header<br />In the Value property of the newly created grouping header, add a calculation for the desired color based on a running value of a count distinct of the containing group expression.<br />For example: <font face="Courier New" size="2">=iif(RunningValue(Fields!Country.Value,CountDistinct,Nothing) Mod 2, "AliceBlue", "White")</font><br />Note: If you have more than one row grouping, you may need to do the count distinct on the combination of all group expressions, like this:<br /><font face="Courier New" size="2">=iif(RunningValue(Fields!Country.Value & CStr(Fields!Year.Value),CountDistinct,Nothing) Mod 2, "AliceBlue", "White")</font></p> <p><strong>Step 3:</strong> Set the background color of the inner row grouping header to =Value</p> <p><strong>Step 4:</strong> Set the background color of the matrix data cell to the value of the inner row grouping header<br />For example: <font face="Courier New" size="2">=ReportItems!ColorNameTextbox.Value</font></p> <p><strong>Step 5:</strong> Set the background color of the outer row grouping header<br />You'll need to use the same expression here that you used for the Value of the inner row grouping header.</p> <p><strong>Step 6:</strong> "Cloak" the inner row grouping header (so it looks like part of of the outer grouping header)<br />Set the right border style of the outer grouping header to None.<br />Set the left border style of the inner grouping header to None.<br />Set the font weight of the inner grouping header to 1 pt.<br />Set the font color of the inner grouping header to =Value.<br />Set the CanGrow property of the inner grouping header to False.<br />Drag the inner grouping header to be as narrow as possible.<br />Optional: Hand-edit the RDL to set the width of the inner grouping header to 0in.</p> <p>A full working sample of green-bar matrix is available here: <A href="http://blogs.msdn.com/chrishays/articles/223066.aspx">http://blogs.msdn.com/chrishays/articles/223066.aspx</a></p> <p> </p><img src ="http://blogs.msdn.com/chrishays/aggbug/223068.aspx" width = "1" height = "1" />
|
URL
|
|
|
Rating
Not Rated
|
|
|
Number of Hits
8
|
Number of Views
416
|
|
Categories
General
Suggest a category for this blog |
Last Updated
No Feed
|
|
Location
United States
Suggest a location for this blog |
Date Added
Jan 17, 2005
|
|
User Comments
Add a comment for this blog
There are currently no comments for this blog! |
|
Add a Comment For This Blog
Please keep comments clean and pertaining to this blog or they will not be added.