Showing posts with label matrix. Show all posts
Showing posts with label matrix. Show all posts

Tuesday, March 27, 2012

Combining Table and Matrix format in one Report in RS2005

Hello,

I am using RS 2005 trying to create the following report. My report consists of the following columns: Question, Sub Question, N as Number of Responses, All as Average for all responses per given question and sub question, and Ethnicity column which is presented here in a Matrix format with ethnic group as columns and average response as Data values. It looks like my challenge is to combine Matrix format report (Ethnicity column) with a data such as N and All columns which are more like a table format. Any input how I could tackle this is greatly appreciated.

Thank you!

--

1.How often have you done each of the following?

N All F M Asian Multi-cultural a. Worked on a paper or project that required integrating ideas or information from various sources 1134 3.96 3.95 3.99 3.54 4.50 b. Used library resources 1132 4.21 4.26 4.09 4.12 4.33 c. Prepared multiple drafts of a paper or assignment before turning it in 1130 3.90 3.97 3.76 3.80 4.50

-How the source data looks like?sqlsql

Tuesday, March 20, 2012

Combine table and matrix with different dataset

Hello all,
I need to combine table and matrix.. Problem is that they have
different dataset and matrix depends from info from table. In table I
show user info and in matrix i should show user activity by event
type...
I did it with subreport... It very-very slow.. SQL for both dataset are
pretty fast. But when I use subreport it became to be extrimely slow...
Is there some other way to do such kind of task?
Thank youTry using Jump to report Using Navigation in the properties tab,Hope It
serves better
Regards
Raj Deep.A
vetaldj wrote:
> Hello all,
> I need to combine table and matrix.. Problem is that they have
> different dataset and matrix depends from info from table. In table I
> show user info and in matrix i should show user activity by event
> type...
> I did it with subreport... It very-very slow.. SQL for both dataset are
> pretty fast. But when I use subreport it became to be extrimely slow...
> Is there some other way to do such kind of task?
> Thank you|||Unfortunatley I can use it...
I need to show matrix right after information about user.. I can't just
navigate user to other report...
Thanks for idea.. I think it will be usefull for some other reports...
Is there some other way to do it?
RajDeep wrote:
> Try using Jump to report Using Navigation in the properties tab,Hope It
> serves better
> Regards
> Raj Deep.A
> vetaldj wrote:
> > Hello all,
> >
> > I need to combine table and matrix.. Problem is that they have
> > different dataset and matrix depends from info from table. In table I
> > show user info and in matrix i should show user activity by event
> > type...
> > I did it with subreport... It very-very slow.. SQL for both dataset are
> > pretty fast. But when I use subreport it became to be extrimely slow...
> >
> > Is there some other way to do such kind of task?
> >
> > Thank you

Monday, March 19, 2012

Combine Chart and Matrix on page

I want to combine my matrix and my chart for the current selection on
a single page.
As it is now, I'm stick with all of the results and the chart below
in. I also have parenting on the left side... however... the only
way for my chart to show the selection from the left, I have to put it
on page break. When I do that, my chart gets pushed to the very
last page of the report.
How can I get the chart to stay on the current parent selection
results and reflect the selected change?On Sep 20, 2:04 pm, Bruce Lawrence <BL32...@.gmail.com> wrote:
> I want to combine my matrix and my chart for the current selection on
> a single page.
> As it is now, I'm stick with all of the results and the chart below
> in. I also have parenting on the left side... however... the only
> way for my chart to show the selection from the left, I have to put it
> on page break. When I do that, my chart gets pushed to the very
> last page of the report.
> How can I get the chart to stay on the current parent selection
> results and reflect the selected change?
I'm not sure if I understand you, but you might try including the
chart and matrix control inside a single rectangle. Hope this helps.
Regards,
Enrique Martinez
Sr. Software Consultant

Saturday, February 25, 2012

Column Order in Matrix

Using SRS 2000.
When creating a matrix report, can you order the columns? By default, they
are in alpha order. My columns are the months of the year. Using Order By
in the query doesn't work.
I want January, February..., not April, August...If you have an actual DateTime field in the dataset, you could just add a
sort expression on the matrix column grouping like
=Month(Fields!SalesDate.Value)
If the column groupings are just based on a string field that actually
contains the month names and there are no other fields that would provide
full datetime information, you could create some "faked" datetime object
based on your month string and then use a sorting expression like
=Month(DateValue(Fields!MonthNameString.Value & " 1, 2005"))
See also:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vafctmonth.asp
http://msdn.microsoft.com/library/en-us/vblr7/html/vafctDateValue.asp
-- Robert
This posting is provided "AS IS" with no warranties, and confers no rights.
"del" <del@.discussions.microsoft.com> wrote in message
news:0CFB34D1-4ACA-4418-A0F6-F5278AFE48AF@.microsoft.com...
> Using SRS 2000.
> When creating a matrix report, can you order the columns? By default,
> they
> are in alpha order. My columns are the months of the year. Using Order
> By
> in the query doesn't work.
> I want January, February..., not April, August...|||Thanks for that. That converts the string to the month number, but it
doesn't sort them 1,2,3... It's still in the same order, but with numbers.
I thought I was being smart by converting in the query using datepart and
datename.
I will look through the info you gave.
"Robert Bruckner [MSFT]" wrote:
> If you have an actual DateTime field in the dataset, you could just add a
> sort expression on the matrix column grouping like
> =Month(Fields!SalesDate.Value)
> If the column groupings are just based on a string field that actually
> contains the month names and there are no other fields that would provide
> full datetime information, you could create some "faked" datetime object
> based on your month string and then use a sorting expression like
> =Month(DateValue(Fields!MonthNameString.Value & " 1, 2005"))
> See also:
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vafctmonth.asp
> http://msdn.microsoft.com/library/en-us/vblr7/html/vafctDateValue.asp
> -- Robert
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> "del" <del@.discussions.microsoft.com> wrote in message
> news:0CFB34D1-4ACA-4418-A0F6-F5278AFE48AF@.microsoft.com...
> > Using SRS 2000.
> >
> > When creating a matrix report, can you order the columns? By default,
> > they
> > are in alpha order. My columns are the months of the year. Using Order
> > By
> > in the query doesn't work.
> >
> > I want January, February..., not April, August...
>
>|||Here's what I did:
In the query, I used date(mm,field) to convert the date in to a month. Then
In the matrix report, I sorted by order and used the monthname function. So
after it was sorted numerically, I used the expression,
=monthname(Field!...Value) and it returns the name of the month.
I would have never looked if you hadn't pointed me in the right direction.
Thanks!
"del" wrote:
> Thanks for that. That converts the string to the month number, but it
> doesn't sort them 1,2,3... It's still in the same order, but with numbers.
> I thought I was being smart by converting in the query using datepart and
> datename.
> I will look through the info you gave.
> "Robert Bruckner [MSFT]" wrote:
> > If you have an actual DateTime field in the dataset, you could just add a
> > sort expression on the matrix column grouping like
> > =Month(Fields!SalesDate.Value)
> >
> > If the column groupings are just based on a string field that actually
> > contains the month names and there are no other fields that would provide
> > full datetime information, you could create some "faked" datetime object
> > based on your month string and then use a sorting expression like
> > =Month(DateValue(Fields!MonthNameString.Value & " 1, 2005"))
> > See also:
> > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vafctmonth.asp
> > http://msdn.microsoft.com/library/en-us/vblr7/html/vafctDateValue.asp
> >
> > -- Robert
> > This posting is provided "AS IS" with no warranties, and confers no rights.
> >
> >
> > "del" <del@.discussions.microsoft.com> wrote in message
> > news:0CFB34D1-4ACA-4418-A0F6-F5278AFE48AF@.microsoft.com...
> > > Using SRS 2000.
> > >
> > > When creating a matrix report, can you order the columns? By default,
> > > they
> > > are in alpha order. My columns are the months of the year. Using Order
> > > By
> > > in the query doesn't work.
> > >
> > > I want January, February..., not April, August...
> >
> >
> >

Column Number function in a matrix?

I have a matrix and would like to be able to add to the column titles
the column number. I have been looking for a function maybe similar
to the rownumber() function, but cannot locate anything for column
number. Is this a possibility?
Thanks!On Jun 26, 6:42 pm, Just Another Reporter <Crystal.War...@.gmail.com>
wrote:
> I have a matrix and would like to be able to add to the column titles
> the column number. I have been looking for a function maybe similar
> to the rownumber() function, but cannot locate anything for column
> number. Is this a possibility?
> Thanks!
The best way to add this functionality is to add an extra column to
your dataset (query/stored procedure results) giving the column rank
(so to speak). If there are a manageable number of column values to
pivot, you can use case statements in the query/stored procedure to
assign the column rank value. Hope this helps.
Regards,
Enrique Martinez
Sr. Software Consultant

Friday, February 24, 2012

Column Headings on Matrix

Hi everyone, this may be a very stupid question or a stupid way of doing
things, but I have a report in a matrix in the following format:
--Year
--Month
Customer--Part--Currency--=Sum(Amount)
The problem I'm having is that above the columns, there is one textbox
merged across all 3 columns and across both rows, but no column headings
appear. Is there anyway to have column headings? We've experimented with
adding a table inside that merged textbox and adding static headings into it,
but this table will not export into Excel.
Any help would be greatly appreciated.Instead of a table, try a rectangle. You can manually place textboxes
inside the rectangle. (Not as convenient as a table, but it should work
with the Excel renderer).
--
This post is provided 'AS IS' with no warranties, and confers no rights. All
rights reserved. Some assembly required. Batteries not included. Your
mileage may vary. Objects in mirror may be closer than they appear. No user
serviceable parts inside. Opening cover voids warranty. Keep out of reach of
children under 3.
"Jeremy" <Jeremy@.discussions.microsoft.com> wrote in message
news:59C51C17-AD76-499F-AE6C-892132117242@.microsoft.com...
> Hi everyone, this may be a very stupid question or a stupid way of doing
> things, but I have a report in a matrix in the following format:
> --Year
> --Month
> Customer--Part--Currency--=Sum(Amount)
> The problem I'm having is that above the columns, there is one textbox
> merged across all 3 columns and across both rows, but no column headings
> appear. Is there anyway to have column headings? We've experimented with
> adding a table inside that merged textbox and adding static headings into
it,
> but this table will not export into Excel.
> Any help would be greatly appreciated.

Sunday, February 19, 2012

Column headers for Matrix

I am developing a matrix report in SRS. In columns group there are several values. When report runs they apper in any order based on the first record in row group. I want colums to apeear in specific order all the time. For example the column sequence in one out put is Follwup 1, Initial , Followup 2. I want to column header to be in order of Initial, Folloup 1, Followup 2.

Can someone help?

You'll need to add another column like Sort or Rank and populate that accordingly. Then sort the output based on that column. If you have several columns that are dynamic that would be best.

pseudo-code for the sort column in your SQL would be:
Case
When "Followup 1" Then 1
When "Initial" Then 2
When "Followup 2" Then 3
End as MyCustomRank

You can also use an expression in the matrix sort...same concept. The pseduo-code for that would be

=IIF(Fields!YOURFIELD.Value = "Followup 1", 1, IIF(Fields!YOURField.Value = "Initial", 2..... and so on

|||

Thank You very much

It worked!

Column headers for Matrix

I am developing a matrix report in SRS. In columns group there are several values. When report runs they apper in any order based on the first record in row group. I want colums to apeear in specific order all the time. For example the column sequence in one out put is Follwup 1, Initial , Followup 2. I want to column header to be in order of Initial, Folloup 1, Followup 2.

Can someone help?

You'll need to add another column like Sort or Rank and populate that accordingly. Then sort the output based on that column. If you have several columns that are dynamic that would be best.

pseudo-code for the sort column in your SQL would be:
Case
When "Followup 1" Then 1
When "Initial" Then 2
When "Followup 2" Then 3
End as MyCustomRank

You can also use an expression in the matrix sort...same concept. The pseduo-code for that would be

=IIF(Fields!YOURFIELD.Value = "Followup 1", 1, IIF(Fields!YOURField.Value = "Initial", 2..... and so on

|||

Thank You very much

It worked!

Column Header Problems in PDF exports

Hi. I have some matrix style reports that many customers export to PDF.
Most of these are quite large files and span numerous pages. The first 3 - 4
pages of the report look great, then after that the column header is pushed
down into the first data row of the report.
Has anyone run into this or know of a workaround etc.?
Thanks in advance.this is a known microsoft bug is what i found out
"comet61" wrote:
> Hi. I have some matrix style reports that many customers export to PDF.
> Most of these are quite large files and span numerous pages. The first 3 - 4
> pages of the report look great, then after that the column header is pushed
> down into the first data row of the report.
> Has anyone run into this or know of a workaround etc.?
> Thanks in advance.

Column Header for Matrix Report

I have a matrix report, which looks like the following:

Header C Header D

Column A Column B Column C Column D

Column A and B are Row Group columns in the matrix. Column C and D are the details columns. How can I add column header to column A and B. Seems I cannot do it in Reporting Services 2005.

Fan

Yes, you can not able to achieve this with Matrices currently and we are hoping to make it possible in our next release.

Workaround: Now you can get this with placing text boxes in the corner of the Matrix which aligns to these cloumns make it give a similar look.

Column Groups : Help with Matrix Report

I have a table that has 2 colums
Project Probablity
1 15
2 89
3 12
4 22
5 7
6 11
7 43
8 92
9 63
10 87
...n ...n
I have to show report that has to show the no. of projects that fall
in the probability 1-10,11-20,21-30,...,91-100
I want to show it in a matrix, Iam just confused about the column
groups and row groups. Can someone hint me how i can achieve this in
matrix ?
thanks
anand sagarYou can group on an expression like this:
=Ceiling(Fields!Probability.Value/10)
And then show this calculation: Count(Fields!Project.Value)
I'm not sure why you want to show this in a matrix since there's only one
axis. I'm assuming that's because you want it to be displayed horizontally.
For that, you would need the row grouping to be static. See this blog entry
for more details:
http://blogs.msdn.com/chrishays/archive/2004/07/23/193292.aspx
--
This post is provided 'AS IS' with no warranties, and confers no rights. All
rights reserved. Some assembly required. Batteries not included. Your
mileage may vary. Objects in mirror may be closer than they appear. No user
serviceable parts inside. Opening cover voids warranty. Keep out of reach of
children under 3.
"Anand Sagar" <anandsagar@.gmail.com> wrote in message
news:3f76a771.0408300414.50d12d6b@.posting.google.com...
> I have a table that has 2 colums
> Project Probablity
> 1 15
> 2 89
> 3 12
> 4 22
> 5 7
> 6 11
> 7 43
> 8 92
> 9 63
> 10 87
> ...n ...n
>
> I have to show report that has to show the no. of projects that fall
> in the probability 1-10,11-20,21-30,...,91-100
> I want to show it in a matrix, Iam just confused about the column
> groups and row groups. Can someone hint me how i can achieve this in
> matrix ?
>
> thanks
> anand sagar

Column Group Row Alignment - Matrix

I just can not understand why when I add text to a group header the report displays more group row space but when I export to excel the extra space disappears....

What the....Help Microsoft please explain...

Thank You...

Any help on this would be great...

Please

Column Group Footers in a Horizontal Report

Hi all.

I've created a horizontal report using a matrix according to the quite useful article Horizontal Tables, but there's one thing I'm trying to do that I'm not having any luck figuring out how to do, and that is creating a footer column for a column group that contains a sum of the values in some of its columns.

In other words, here's how I would like to have it look...

Jan

Feb

Mar

Quarter 1 Total

Apr

May

Jun

Quarter 2 Total

Tier 1

$100

$100

$100

$300

$0

$0

$100

$100

Tier 2

$50

$50

$0

$100

$100

$100

$100

$300

The fields in the dataset are Month, Tier1, Tier2, Year and Quarter. I've created a group on Year & Quarter, tried right clicking and selecting Subtotal, but that seems to add a subtotal column after every month, not at the end of the quarter group as I want.

Any ideas on what I need to do? Is this even possible?

TIA

If you create a matrix with a row grouping of the Tier field and a two column groupings you can get pretty close to what you are looking for.

For the column groupings, create a grouping for the Year and Quarter (2 expressions for the this group) and create another, inner grouping for the Month. Then, place the subtotal month grouping.

You should get something like:

Quarter 1Quarter 2Jan

Feb

Mar

Quarter 1 Total

Apr

May

Jun

Quarter 2 Total

Tier 1

$100

$100

$100

$300

$0

$0

$100

$100

Tier 2

$50

$50

$0

$100

$100

$100

$100

$300

Here is example RDL using the Northwind database.

<?xml version="1.0" encoding="utf-8"?>
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<DataSources>
<DataSource Name="DataSource1">
<ConnectionProperties>
<IntegratedSecurity>true</IntegratedSecurity>
<ConnectString>Initial Catalog=Northwind; data source=localhost</ConnectString>
<DataProvider>SQL</DataProvider>
</ConnectionProperties>
</DataSource>
</DataSources>
<BottomMargin>1in</BottomMargin>
<RightMargin>1in</RightMargin>
<rd:DrawGrid>true</rd:DrawGrid>
<InteractiveWidth>8.5in</InteractiveWidth>
<rd:SnapToGrid>true</rd:SnapToGrid>
<Body>
<ReportItems>
<Matrix Name="matrix1">
<MatrixColumns>
<MatrixColumn>
<Width>1in</Width>
</MatrixColumn>
</MatrixColumns>
<Left>1in</Left>
<RowGroupings>
<RowGrouping>
<Width>1in</Width>
<DynamicRows>
<ReportItems>
<Textbox Name="ShipCountry">
<rd:DefaultName>ShipCountry</rd:DefaultName>
<ZIndex>1</ZIndex>
<Style>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
</Style>
<CanGrow>true</CanGrow>
<Value>=Fields!ShipCountry.Value</Value>
</Textbox>
</ReportItems>
<Grouping Name="matrix1_ShipCountry">
<GroupExpressions>
<GroupExpression>=Fields!ShipCountry.Value</GroupExpression>
</GroupExpressions>
</Grouping>
</DynamicRows>
</RowGrouping>
</RowGroupings>
<ColumnGroupings>
<ColumnGrouping>
<DynamicColumns>
<ReportItems>
<Textbox Name="OrderDate">
<rd:DefaultName>OrderDate</rd:DefaultName>
<ZIndex>4</ZIndex>
<Style>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
</Style>
<CanGrow>true</CanGrow>
<Value>=Fields!OrderDate.Value.Year &amp; " - " &amp; Fields!OrderDate.Value.Month</Value>
</Textbox>
</ReportItems>
<Grouping Name="matrix1_OrderDate">
<GroupExpressions>
<GroupExpression>=Fields!OrderDate.Value.Year</GroupExpression>
<GroupExpression>=Cint((Fields!OrderDate.Value.Month+1)/3)</GroupExpression>
</GroupExpressions>
</Grouping>
</DynamicColumns>
<Height>0.25in</Height>
</ColumnGrouping>
<ColumnGrouping>
<DynamicColumns>
<ReportItems>
<Textbox Name="OrderDate_1">
<rd:DefaultName>OrderDate_1</rd:DefaultName>
<ZIndex>3</ZIndex>
<Style>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
</Style>
<CanGrow>true</CanGrow>
<Value>=Fields!OrderDate.Value.Month</Value>
</Textbox>
</ReportItems>
<Subtotal>
<ReportItems>
<Textbox Name="textbox3">
<rd:DefaultName>textbox3</rd:DefaultName>
<ZIndex>2</ZIndex>
<Style>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<Color>Red</Color>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
</Style>
<CanGrow>true</CanGrow>
<Value>Total</Value>
</Textbox>
</ReportItems>
<Style>
<Color>Red</Color>
</Style>
</Subtotal>
<Grouping Name="matrix1_ColumnGroup1">
<GroupExpressions>
<GroupExpression>=Fields!OrderDate.Value.Month</GroupExpression>
</GroupExpressions>
</Grouping>
</DynamicColumns>
<Height>0.25in</Height>
</ColumnGrouping>
</ColumnGroupings>
<DataSetName>DataSet2</DataSetName>
<Top>1.125in</Top>
<Width>3in</Width>
<Corner>
<ReportItems>
<Textbox Name="textbox1">
<rd:DefaultName>textbox1</rd:DefaultName>
<ZIndex>5</ZIndex>
<Style>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
</Style>
<CanGrow>true</CanGrow>
<Value />
</Textbox>
</ReportItems>
</Corner>
<Height>0.75in</Height>
<MatrixRows>
<MatrixRow>
<Height>0.25in</Height>
<MatrixCells>
<MatrixCell>
<ReportItems>
<Textbox Name="Quantity">
<rd:DefaultName>Quantity</rd:DefaultName>
<Style>
<TextAlign>Right</TextAlign>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
</Style>
<CanGrow>true</CanGrow>
<Value>=Sum(Fields!Quantity.Value)</Value>
</Textbox>
</ReportItems>
</MatrixCell>
</MatrixCells>
</MatrixRow>
</MatrixRows>
</Matrix>
</ReportItems>
<Height>2.25in</Height>
</Body>
<rd:ReportID>69d1d3a8-e0a0-4c9b-b63e-d7204e0f8f21</rd:ReportID>
<LeftMargin>1in</LeftMargin>
<DataSets>
<DataSet Name="DataSet2">
<Query>
<rd:UseGenericDesigner>true</rd:UseGenericDesigner>
<CommandText>Select ShipCountry, OrderDate, Quantity from orders inner join [order details] on orders.orderid = [order details].orderid</CommandText>
<DataSourceName>SharedNorthwind</DataSourceName>
</Query>
<Fields>
<Field Name="ShipCountry">
<rd:TypeName>System.String</rd:TypeName>
<DataField>ShipCountry</DataField>
</Field>
<Field Name="OrderDate">
<rd:TypeName>System.DateTime</rd:TypeName>
<DataField>OrderDate</DataField>
</Field>
<Field Name="Quantity">
<rd:TypeName>System.Int16</rd:TypeName>
<DataField>Quantity</DataField>
</Field>
</Fields>
</DataSet>
</DataSets>
<Width>6.5in</Width>
<InteractiveHeight>11in</InteractiveHeight>
<Language>en-US</Language>
<TopMargin>1in</TopMargin>
</Report>

Column Descriptions in Matrix

Is there a way to have a column description/header for each column in a matrix?Try setting the ToolTip property on the textbox in the column header. If it's an expression, make sure it returns a string value.

Tuesday, February 14, 2012

Colspan in reports?

Is it possible to manipulate table or matrix cells with colspan in reports?
I have several reports that show Client and Project.
Currently, the only way I have to display it is like this:
Clientname
..............Project
What I want to do is like this:
Clientname
....Project
Is it possible to do this? How? Conditionally merge cells?
All help appreicated!
Kaisa M. LindahlYou are correct, merge the cells to get a colspan in a table. Simply
highlight the cells you want to merge (in the report designer) and
right click. You'll see then the option to Merge Cells.|||<cmarinella@.gmail.com> wrote in message
news:1104769372.216591.197530@.c13g2000cwb.googlegroups.com...
> You are correct, merge the cells to get a colspan in a table. Simply
> highlight the cells you want to merge (in the report designer) and
> right click. You'll see then the option to Merge Cells.
>
Ah, nice.
But I can only make it work in table view. Is it possible to do something
like it in matrix too?
Kaisa M. Lindahl

Sunday, February 12, 2012

Color Property Formatting not working correctly

Hi,

I have a problem with a conditional format of the Color property in a matrix report. When the value of the textbox is greater than 0, the color should be Red otherwise it should be Blue. This is implemented via an IIF statement and works perfectly in Preview in Visual Studio 2005.

When the report is deployed, the formatting appears to be ignored and all values are the default value of Black.

Anyone else experienced this problem and, if so, is there a workaround?

I wish I could help you, however I cannot.

I can however state with confidence that posting 7 times in roughly 1 hour about the same thing is not the best way to get the attention of those who can.

Just my

|||Yea I can't help you either. . .|||

I agree with the sentiment in the above posts - spamming a forum is not the best way to get an answer.

What would also help is if you posted the expression you are using - without it we are just guessing.

Color Property Formatting not working

Hi,

I have a problem with a conditional format of the Color property in a matrix report. When the value of the textbox is greater than 0, the color should be Red otherwise it should be Blue. This is implemented via an IIF statement and works perfectly in Preview in Visual Studio 2005.

When the report is deployed, the formatting appears to be ignored and all values are the default value of Black.

Anyone else experienced this problem and, if so, is there a workaround?

Thanks in advance

If I am not wrong, matrix conditional formatting is applied by default at the details. You may need to do scope it at the right level, e.g.; =Iif(SUM(<field name, "group name")>0, "Red", "Blue"). Also, download your deployed report definition from the Report Manager (General report properties) and make sure the expression is there.

Color inconsistent on each slice of Pie

Hello all!!
I have created a pie chart that is embedded in a matrix report, therefore
creating a new pie for every row. The problem I am having is the pie slice
for the same series is changing each time there is a new pie. For example,
in the first pie Cars may be designated as green but in the second pie it may
be red. I would like the colors to be consistent; all cars are represented
as green slices. Oh and if there are no cars don't use the color green for
another slice.
I think this can be done using a nested expression but I am unsure how to
write it...I either need an example of an expression that can handle
multiple slices or another way to handle the issue.
Thanks,
AnthonyI suggest to follow the approach discussed in this blog article:
http://blogs.msdn.com/bwelcker/archive/2005/05/20/420349.aspx
You don't need the part about the custom legend, but you should take a close
look at the custom color part of the sample. You can modify the code so that
instead of having the hashtable approach to apply unique colors for
categories, you replace it with some IF statement to explicitly control
colors.
A trivial RDL sample with two charts using different filters but sharing the
same colors for categories is copied to the bottom of this posting.
-- Robert
This posting is provided "AS IS" with no warranties, and confers no rights.
"anthonysjo" <anthonysjo@.discussions.microsoft.com> wrote in message
news:69E297FD-F5C7-44D4-9463-5E4871B1CEAB@.microsoft.com...
> Hello all!!
> I have created a pie chart that is embedded in a matrix report, therefore
> creating a new pie for every row. The problem I am having is the pie
> slice
> for the same series is changing each time there is a new pie. For
> example,
> in the first pie Cars may be designated as green but in the second pie it
> may
> be red. I would like the colors to be consistent; all cars are
> represented
> as green slices. Oh and if there are no cars don't use the color green
> for
> another slice.
> I think this can be done using a nested expression but I am unsure how to
> write it...I either need an example of an expression that can handle
> multiple slices or another way to handle the issue.
> Thanks,
> Anthony
============================================
<?xml version="1.0" encoding="utf-8"?>
<Report
xmlns="http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefinition"
xmlns:rd="">http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<RightMargin>1in</RightMargin>
<Author>Robert M. Bruckner</Author>
<Body>
<ReportItems>
<Chart Name="chart2">
<ThreeDProperties>
<Rotation>30</Rotation>
<Inclination>30</Inclination>
<Shading>Simple</Shading>
<WallThickness>50</WallThickness>
</ThreeDProperties>
<ZIndex>1</ZIndex>
<Style>
<BackgroundColor>White</BackgroundColor>
</Style>
<Legend>
<Visible>true</Visible>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
<Position>RightCenter</Position>
</Legend>
<Palette>Default</Palette>
<ChartData>
<ChartSeries>
<DataPoints>
<DataPoint>
<DataValues>
<DataValue>
<Value>=Sum(Fields!UnitsInStock.Value)</Value>
</DataValue>
</DataValues>
<DataLabel />
<Style>
<BackgroundColor>=Code.GetColor(Fields!CategoryName.Value)</BackgroundColor>
</Style>
<Marker>
<Size>6pt</Size>
</Marker>
</DataPoint>
</DataPoints>
</ChartSeries>
</ChartData>
<CategoryAxis>
<Axis>
<Title />
<MajorGridLines>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</MajorGridLines>
<MinorGridLines>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</MinorGridLines>
<Min>0</Min>
</Axis>
</CategoryAxis>
<DataSetName>DataSet1</DataSetName>
<PointWidth>0</PointWidth>
<Type>Bar</Type>
<Top>3.125in</Top>
<Title>
<Caption>UK</Caption>
</Title>
<Width>6in</Width>
<SeriesGroupings>
<SeriesGrouping>
<DynamicSeries>
<Grouping Name="chart2_SeriesGroup1">
<GroupExpressions>
<GroupExpression>=Fields!CategoryName.Value</GroupExpression>
</GroupExpressions>
</Grouping>
<Sorting>
<SortBy>
<SortExpression>=Fields!CategoryName.Value</SortExpression>
<Direction>Ascending</Direction>
</SortBy>
</Sorting>
<Label>=Fields!CategoryName.Value</Label>
</DynamicSeries>
</SeriesGrouping>
</SeriesGroupings>
<Subtype>Plain</Subtype>
<PlotArea>
<Style>
<BackgroundColor>LightGrey</BackgroundColor>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</PlotArea>
<Filters>
<Filter>
<FilterExpression>=Fields!Country.Value</FilterExpression>
<Operator>Equal</Operator>
<FilterValues>
<FilterValue>UK</FilterValue>
</FilterValues>
</Filter>
</Filters>
<Left>0.125in</Left>
<ValueAxis>
<Axis>
<Title />
<MajorGridLines>
<ShowGridLines>true</ShowGridLines>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</MajorGridLines>
<MinorGridLines>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</MinorGridLines>
<MajorTickMarks>Outside</MajorTickMarks>
<Min>0</Min>
<Margin>true</Margin>
<Visible>true</Visible>
<Scalar>true</Scalar>
</Axis>
</ValueAxis>
</Chart>
<Chart Name="chart1">
<ThreeDProperties>
<Rotation>30</Rotation>
<Inclination>30</Inclination>
<Shading>Simple</Shading>
<WallThickness>50</WallThickness>
</ThreeDProperties>
<Style>
<BackgroundColor>White</BackgroundColor>
</Style>
<Legend>
<Visible>true</Visible>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
<Position>RightCenter</Position>
</Legend>
<Palette>Default</Palette>
<ChartData>
<ChartSeries>
<DataPoints>
<DataPoint>
<DataValues>
<DataValue>
<Value>=Sum(Fields!UnitsInStock.Value)</Value>
</DataValue>
</DataValues>
<DataLabel />
<Style>
<BackgroundColor>=Code.GetColor(Fields!CategoryName.Value)</BackgroundColor>
</Style>
<Marker>
<Size>6pt</Size>
</Marker>
</DataPoint>
</DataPoints>
</ChartSeries>
</ChartData>
<CategoryAxis>
<Axis>
<Title />
<MajorGridLines>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</MajorGridLines>
<MinorGridLines>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</MinorGridLines>
<Min>0</Min>
</Axis>
</CategoryAxis>
<DataSetName>DataSet1</DataSetName>
<PointWidth>0</PointWidth>
<Type>Bar</Type>
<Top>0.25in</Top>
<Title>
<Caption>USA</Caption>
</Title>
<Width>6in</Width>
<Height>2.5in</Height>
<SeriesGroupings>
<SeriesGrouping>
<DynamicSeries>
<Grouping Name="chart1_SeriesGroup1">
<GroupExpressions>
<GroupExpression>=Fields!CategoryName.Value</GroupExpression>
</GroupExpressions>
</Grouping>
<Sorting>
<SortBy>
<SortExpression>=Fields!CategoryName.Value</SortExpression>
<Direction>Ascending</Direction>
</SortBy>
</Sorting>
<Label>=Fields!CategoryName.Value</Label>
</DynamicSeries>
</SeriesGrouping>
</SeriesGroupings>
<Subtype>Plain</Subtype>
<PlotArea>
<Style>
<BackgroundColor>LightGrey</BackgroundColor>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</PlotArea>
<Filters>
<Filter>
<FilterExpression>=Fields!Country.Value</FilterExpression>
<Operator>Equal</Operator>
<FilterValues>
<FilterValue>USA</FilterValue>
</FilterValues>
</Filter>
</Filters>
<Left>0.125in</Left>
<ValueAxis>
<Axis>
<Title />
<MajorGridLines>
<ShowGridLines>true</ShowGridLines>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</MajorGridLines>
<MinorGridLines>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</MinorGridLines>
<MajorTickMarks>Outside</MajorTickMarks>
<Min>0</Min>
<Margin>true</Margin>
<Visible>true</Visible>
<Scalar>true</Scalar>
</Axis>
</ValueAxis>
</Chart>
</ReportItems>
<Style />
<Height>5.625in</Height>
</Body>
<TopMargin>1in</TopMargin>
<DataSources>
<DataSource Name="Northwind">
<rd:DataSourceID>f646058b-4784-494d-a09d-27fde13a5679</rd:DataSourceID>
<ConnectionProperties>
<DataProvider>SQL</DataProvider>
<ConnectString>data source=(local);initial
catalog=Northwind</ConnectString>
<IntegratedSecurity>true</IntegratedSecurity>
</ConnectionProperties>
</DataSource>
</DataSources>
<Code> Private colorPalette As String() = {"Green", "Blue", "Red",
"Orange", "Aqua", "Teal", "Gold", "RoyalBlue", "#A59D93", "#B8341B",
"#352F26", "#F1E7D6", "#E16C56", "#CFBA9B"}
Private count As Integer = 0
Private mapping As New System.Collections.Hashtable()
Public Function GetColor(ByVal groupingValue As String) As String
If mapping.ContainsKey(groupingValue) Then
Return mapping(groupingValue)
End If
Dim c As String = colorPalette(count Mod colorPalette.Length)
count = count + 1
mapping.Add(groupingValue, c)
Return c
End Function
</Code>
<Width>6.5in</Width>
<DataSets>
<DataSet Name="DataSet1">
<Fields>
<Field Name="ProductID">
<DataField>ProductID</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
<Field Name="ProductName">
<DataField>ProductName</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="SupplierID">
<DataField>SupplierID</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
<Field Name="CategoryID">
<DataField>CategoryID</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
<Field Name="QuantityPerUnit">
<DataField>QuantityPerUnit</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="UnitPrice">
<DataField>UnitPrice</DataField>
<rd:TypeName>System.Decimal</rd:TypeName>
</Field>
<Field Name="UnitsInStock">
<DataField>UnitsInStock</DataField>
<rd:TypeName>System.Int16</rd:TypeName>
</Field>
<Field Name="UnitsOnOrder">
<DataField>UnitsOnOrder</DataField>
<rd:TypeName>System.Int16</rd:TypeName>
</Field>
<Field Name="ReorderLevel">
<DataField>ReorderLevel</DataField>
<rd:TypeName>System.Int16</rd:TypeName>
</Field>
<Field Name="Discontinued">
<DataField>Discontinued</DataField>
<rd:TypeName>System.Boolean</rd:TypeName>
</Field>
<Field Name="CategoryName">
<DataField>CategoryName</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="Country">
<DataField>Country</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
</Fields>
<Query>
<DataSourceName>Northwind</DataSourceName>
<CommandText>SELECT Products.*, Categories.CategoryName,
Suppliers.Country
FROM Products INNER JOIN
Categories ON Products.CategoryID =Categories.CategoryID INNER JOIN
Suppliers ON Products.SupplierID =Suppliers.SupplierID</CommandText>
</Query>
</DataSet>
</DataSets>
<LeftMargin>1in</LeftMargin>
<rd:SnapToGrid>true</rd:SnapToGrid>
<rd:DrawGrid>true</rd:DrawGrid>
<rd:ReportID>e5564b0f-4fab-4cf7-9cef-bda726589920</rd:ReportID>
<BottomMargin>1in</BottomMargin>
<Language>en-US</Language>
</Report>|||I tried the code in the article but get the following error:
There is an error on line 14 of custom code: [BC30430] 'End Function' must
be preceded by a matching 'Function'.
Build complete -- 1 errors, 0 warnings
Any ideas?
"Robert Bruckner [MSFT]" wrote:
> I suggest to follow the approach discussed in this blog article:
> http://blogs.msdn.com/bwelcker/archive/2005/05/20/420349.aspx
> You don't need the part about the custom legend, but you should take a close
> look at the custom color part of the sample. You can modify the code so that
> instead of having the hashtable approach to apply unique colors for
> categories, you replace it with some IF statement to explicitly control
> colors.
> A trivial RDL sample with two charts using different filters but sharing the
> same colors for categories is copied to the bottom of this posting.
> -- Robert
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> "anthonysjo" <anthonysjo@.discussions.microsoft.com> wrote in message
> news:69E297FD-F5C7-44D4-9463-5E4871B1CEAB@.microsoft.com...
> > Hello all!!
> >
> > I have created a pie chart that is embedded in a matrix report, therefore
> > creating a new pie for every row. The problem I am having is the pie
> > slice
> > for the same series is changing each time there is a new pie. For
> > example,
> > in the first pie Cars may be designated as green but in the second pie it
> > may
> > be red. I would like the colors to be consistent; all cars are
> > represented
> > as green slices. Oh and if there are no cars don't use the color green
> > for
> > another slice.
> >
> > I think this can be done using a nested expression but I am unsure how to
> > write it...I either need an example of an expression that can handle
> > multiple slices or another way to handle the issue.
> >
> > Thanks,
> > Anthony
>
> ============================================> <?xml version="1.0" encoding="utf-8"?>
> <Report
> xmlns="http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefinition"
> xmlns:rd="">http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
> <RightMargin>1in</RightMargin>
> <Author>Robert M. Bruckner</Author>
> <Body>
> <ReportItems>
> <Chart Name="chart2">
> <ThreeDProperties>
> <Rotation>30</Rotation>
> <Inclination>30</Inclination>
> <Shading>Simple</Shading>
> <WallThickness>50</WallThickness>
> </ThreeDProperties>
> <ZIndex>1</ZIndex>
> <Style>
> <BackgroundColor>White</BackgroundColor>
> </Style>
> <Legend>
> <Visible>true</Visible>
> <Style>
> <BorderStyle>
> <Default>Solid</Default>
> </BorderStyle>
> </Style>
> <Position>RightCenter</Position>
> </Legend>
> <Palette>Default</Palette>
> <ChartData>
> <ChartSeries>
> <DataPoints>
> <DataPoint>
> <DataValues>
> <DataValue>
> <Value>=Sum(Fields!UnitsInStock.Value)</Value>
> </DataValue>
> </DataValues>
> <DataLabel />
> <Style>
> <BackgroundColor>=Code.GetColor(Fields!CategoryName.Value)</BackgroundColor>
> </Style>
> <Marker>
> <Size>6pt</Size>
> </Marker>
> </DataPoint>
> </DataPoints>
> </ChartSeries>
> </ChartData>
> <CategoryAxis>
> <Axis>
> <Title />
> <MajorGridLines>
> <Style>
> <BorderStyle>
> <Default>Solid</Default>
> </BorderStyle>
> </Style>
> </MajorGridLines>
> <MinorGridLines>
> <Style>
> <BorderStyle>
> <Default>Solid</Default>
> </BorderStyle>
> </Style>
> </MinorGridLines>
> <Min>0</Min>
> </Axis>
> </CategoryAxis>
> <DataSetName>DataSet1</DataSetName>
> <PointWidth>0</PointWidth>
> <Type>Bar</Type>
> <Top>3.125in</Top>
> <Title>
> <Caption>UK</Caption>
> </Title>
> <Width>6in</Width>
> <SeriesGroupings>
> <SeriesGrouping>
> <DynamicSeries>
> <Grouping Name="chart2_SeriesGroup1">
> <GroupExpressions>
> <GroupExpression>=Fields!CategoryName.Value</GroupExpression>
> </GroupExpressions>
> </Grouping>
> <Sorting>
> <SortBy>
> <SortExpression>=Fields!CategoryName.Value</SortExpression>
> <Direction>Ascending</Direction>
> </SortBy>
> </Sorting>
> <Label>=Fields!CategoryName.Value</Label>
> </DynamicSeries>
> </SeriesGrouping>
> </SeriesGroupings>
> <Subtype>Plain</Subtype>
> <PlotArea>
> <Style>
> <BackgroundColor>LightGrey</BackgroundColor>
> <BorderStyle>
> <Default>Solid</Default>
> </BorderStyle>
> </Style>
> </PlotArea>
> <Filters>
> <Filter>
> <FilterExpression>=Fields!Country.Value</FilterExpression>
> <Operator>Equal</Operator>
> <FilterValues>
> <FilterValue>UK</FilterValue>
> </FilterValues>
> </Filter>
> </Filters>
> <Left>0.125in</Left>
> <ValueAxis>
> <Axis>
> <Title />
> <MajorGridLines>
> <ShowGridLines>true</ShowGridLines>
> <Style>
> <BorderStyle>
> <Default>Solid</Default>
> </BorderStyle>
> </Style>
> </MajorGridLines>
> <MinorGridLines>
> <Style>
> <BorderStyle>
> <Default>Solid</Default>
> </BorderStyle>
> </Style>
> </MinorGridLines>
> <MajorTickMarks>Outside</MajorTickMarks>
> <Min>0</Min>
> <Margin>true</Margin>
> <Visible>true</Visible>
> <Scalar>true</Scalar>
> </Axis>
> </ValueAxis>
> </Chart>
> <Chart Name="chart1">
> <ThreeDProperties>
> <Rotation>30</Rotation>
> <Inclination>30</Inclination>
> <Shading>Simple</Shading>
> <WallThickness>50</WallThickness>
> </ThreeDProperties>
> <Style>
> <BackgroundColor>White</BackgroundColor>
> </Style>
> <Legend>
> <Visible>true</Visible>
> <Style>
> <BorderStyle>
> <Default>Solid</Default>
> </BorderStyle>
> </Style>
> <Position>RightCenter</Position>
> </Legend>
> <Palette>Default</Palette>
> <ChartData>
> <ChartSeries>
> <DataPoints>
> <DataPoint>
> <DataValues>
> <DataValue>
> <Value>=Sum(Fields!UnitsInStock.Value)</Value>
> </DataValue>
> </DataValues>
> <DataLabel />
> <Style>
> <BackgroundColor>=Code.GetColor(Fields!CategoryName.Value)</BackgroundColor>
> </Style>
> <Marker>
> <Size>6pt</Size>
> </Marker>
> </DataPoint>
> </DataPoints>
> </ChartSeries>
> </ChartData>
> <CategoryAxis>
> <Axis>
> <Title />
> <MajorGridLines>
> <Style>
> <BorderStyle>
> <Default>Solid</Default>
> </BorderStyle>
> </Style>
> </MajorGridLines>
> <MinorGridLines>
> <Style>
> <BorderStyle>
> <Default>Solid</Default>
> </BorderStyle>
> </Style>
> </MinorGridLines>
> <Min>0</Min>
> </Axis>
> </CategoryAxis>
> <DataSetName>DataSet1</DataSetName>
> <PointWidth>0</PointWidth>
> <Type>Bar</Type>
> <Top>0.25in</Top>
> <Title>
> <Caption>USA</Caption>
> </Title>
> <Width>6in</Width>
> <Height>2.5in</Height>
> <SeriesGroupings>
> <SeriesGrouping>
> <DynamicSeries>
> <Grouping Name="chart1_SeriesGroup1">
> <GroupExpressions>
> <GroupExpression>=Fields!CategoryName.Value</GroupExpression>
> </GroupExpressions>
> </Grouping>
> <Sorting>
> <SortBy>
> <SortExpression>=Fields!CategoryName.Value</SortExpression>
> <Direction>Ascending</Direction>
> </SortBy>
> </Sorting>
> <Label>=Fields!CategoryName.Value</Label>
> </DynamicSeries>
> </SeriesGrouping>
> </SeriesGroupings>
> <Subtype>Plain</Subtype>
> <PlotArea>
> <Style>
> <BackgroundColor>LightGrey</BackgroundColor>
> <BorderStyle>
> <Default>Solid</Default>
> </BorderStyle>
> </Style>
> </PlotArea>
> <Filters>
> <Filter>
> <FilterExpression>=Fields!Country.Value</FilterExpression>
> <Operator>Equal</Operator>
> <FilterValues>
> <FilterValue>USA</FilterValue>
> </FilterValues>
> </Filter>
> </Filters>
> <Left>0.125in</Left>
> <ValueAxis>
> <Axis>
> <Title />
> <MajorGridLines>
> <ShowGridLines>true</ShowGridLines>
> <Style>
> <BorderStyle>
> <Default>Solid</Default>
> </BorderStyle>
> </Style>
> </MajorGridLines>|||Did you try the sample I had attached to the bottom of my previous posting,
or did you download the other sample about custom legends from the blog
article? Both should work as provided.
In your particular case, the error message would indicate that you are
missing the Function keyword for the corresponding End Function statement on
line 14 of the custom code window of the report (VS menu -> report -> report
properties -> custom code)
-- Robert
This posting is provided "AS IS" with no warranties, and confers no rights.
"anthonysjo" <anthonysjo@.discussions.microsoft.com> wrote in message
news:13337779-49F4-44A7-B0B8-4963E58D2B75@.microsoft.com...
>I tried the code in the article but get the following error:
> There is an error on line 14 of custom code: [BC30430] 'End Function' must
> be preceded by a matching 'Function'.
> Build complete -- 1 errors, 0 warnings
>
> Any ideas?
> "Robert Bruckner [MSFT]" wrote:
>> I suggest to follow the approach discussed in this blog article:
>> http://blogs.msdn.com/bwelcker/archive/2005/05/20/420349.aspx
>> You don't need the part about the custom legend, but you should take a
>> close
>> look at the custom color part of the sample. You can modify the code so
>> that
>> instead of having the hashtable approach to apply unique colors for
>> categories, you replace it with some IF statement to explicitly control
>> colors.
>> A trivial RDL sample with two charts using different filters but sharing
>> the
>> same colors for categories is copied to the bottom of this posting.
>> -- Robert
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>>
>> "anthonysjo" <anthonysjo@.discussions.microsoft.com> wrote in message
>> news:69E297FD-F5C7-44D4-9463-5E4871B1CEAB@.microsoft.com...
>> > Hello all!!
>> >
>> > I have created a pie chart that is embedded in a matrix report,
>> > therefore
>> > creating a new pie for every row. The problem I am having is the pie
>> > slice
>> > for the same series is changing each time there is a new pie. For
>> > example,
>> > in the first pie Cars may be designated as green but in the second pie
>> > it
>> > may
>> > be red. I would like the colors to be consistent; all cars are
>> > represented
>> > as green slices. Oh and if there are no cars don't use the color green
>> > for
>> > another slice.
>> >
>> > I think this can be done using a nested expression but I am unsure how
>> > to
>> > write it...I either need an example of an expression that can handle
>> > multiple slices or another way to handle the issue.
>> >
>> > Thanks,
>> > Anthony
>>
>> ============================================>> <?xml version="1.0" encoding="utf-8"?>
>> <Report
>> xmlns="http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefinition"
>> xmlns:rd="">http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
>> <RightMargin>1in</RightMargin>
>> <Author>Robert M. Bruckner</Author>
>> <Body>
>> <ReportItems>
>> <Chart Name="chart2">
>> <ThreeDProperties>
>> <Rotation>30</Rotation>
>> <Inclination>30</Inclination>
>> <Shading>Simple</Shading>
>> <WallThickness>50</WallThickness>
>> </ThreeDProperties>
>> <ZIndex>1</ZIndex>
>> <Style>
>> <BackgroundColor>White</BackgroundColor>
>> </Style>
>> <Legend>
>> <Visible>true</Visible>
>> <Style>
>> <BorderStyle>
>> <Default>Solid</Default>
>> </BorderStyle>
>> </Style>
>> <Position>RightCenter</Position>
>> </Legend>
>> <Palette>Default</Palette>
>> <ChartData>
>> <ChartSeries>
>> <DataPoints>
>> <DataPoint>
>> <DataValues>
>> <DataValue>
>> <Value>=Sum(Fields!UnitsInStock.Value)</Value>
>> </DataValue>
>> </DataValues>
>> <DataLabel />
>> <Style>
>> <BackgroundColor>=Code.GetColor(Fields!CategoryName.Value)</BackgroundColor>
>> </Style>
>> <Marker>
>> <Size>6pt</Size>
>> </Marker>
>> </DataPoint>
>> </DataPoints>
>> </ChartSeries>
>> </ChartData>
>> <CategoryAxis>
>> <Axis>
>> <Title />
>> <MajorGridLines>
>> <Style>
>> <BorderStyle>
>> <Default>Solid</Default>
>> </BorderStyle>
>> </Style>
>> </MajorGridLines>
>> <MinorGridLines>
>> <Style>
>> <BorderStyle>
>> <Default>Solid</Default>
>> </BorderStyle>
>> </Style>
>> </MinorGridLines>
>> <Min>0</Min>
>> </Axis>
>> </CategoryAxis>
>> <DataSetName>DataSet1</DataSetName>
>> <PointWidth>0</PointWidth>
>> <Type>Bar</Type>
>> <Top>3.125in</Top>
>> <Title>
>> <Caption>UK</Caption>
>> </Title>
>> <Width>6in</Width>
>> <SeriesGroupings>
>> <SeriesGrouping>
>> <DynamicSeries>
>> <Grouping Name="chart2_SeriesGroup1">
>> <GroupExpressions>
>> <GroupExpression>=Fields!CategoryName.Value</GroupExpression>
>> </GroupExpressions>
>> </Grouping>
>> <Sorting>
>> <SortBy>
>> <SortExpression>=Fields!CategoryName.Value</SortExpression>
>> <Direction>Ascending</Direction>
>> </SortBy>
>> </Sorting>
>> <Label>=Fields!CategoryName.Value</Label>
>> </DynamicSeries>
>> </SeriesGrouping>
>> </SeriesGroupings>
>> <Subtype>Plain</Subtype>
>> <PlotArea>
>> <Style>
>> <BackgroundColor>LightGrey</BackgroundColor>
>> <BorderStyle>
>> <Default>Solid</Default>
>> </BorderStyle>
>> </Style>
>> </PlotArea>
>> <Filters>
>> <Filter>
>> <FilterExpression>=Fields!Country.Value</FilterExpression>
>> <Operator>Equal</Operator>
>> <FilterValues>
>> <FilterValue>UK</FilterValue>
>> </FilterValues>
>> </Filter>
>> </Filters>
>> <Left>0.125in</Left>
>> <ValueAxis>
>> <Axis>
>> <Title />
>> <MajorGridLines>
>> <ShowGridLines>true</ShowGridLines>
>> <Style>
>> <BorderStyle>
>> <Default>Solid</Default>
>> </BorderStyle>
>> </Style>
>> </MajorGridLines>
>> <MinorGridLines>
>> <Style>
>> <BorderStyle>
>> <Default>Solid</Default>
>> </BorderStyle>
>> </Style>
>> </MinorGridLines>
>> <MajorTickMarks>Outside</MajorTickMarks>
>> <Min>0</Min>
>> <Margin>true</Margin>
>> <Visible>true</Visible>
>> <Scalar>true</Scalar>
>> </Axis>
>> </ValueAxis>
>> </Chart>
>> <Chart Name="chart1">
>> <ThreeDProperties>
>> <Rotation>30</Rotation>
>> <Inclination>30</Inclination>
>> <Shading>Simple</Shading>
>> <WallThickness>50</WallThickness>
>> </ThreeDProperties>
>> <Style>
>> <BackgroundColor>White</BackgroundColor>
>> </Style>
>> <Legend>
>> <Visible>true</Visible>
>> <Style>
>> <BorderStyle>
>> <Default>Solid</Default>
>> </BorderStyle>
>> </Style>
>> <Position>RightCenter</Position>
>> </Legend>
>> <Palette>Default</Palette>
>> <ChartData>
>> <ChartSeries>
>> <DataPoints>
>> <DataPoint>
>> <DataValues>
>> <DataValue>
>> <Value>=Sum(Fields!UnitsInStock.Value)</Value>
>> </DataValue>
>> </DataValues>
>> <DataLabel />
>> <Style>
>> <BackgroundColor>=Code.GetColor(Fields!CategoryName.Value)</BackgroundColor>
>> </Style>
>> <Marker>
>> <Size>6pt</Size>
>> </Marker>
>> </DataPoint>
>> </DataPoints>
>> </ChartSeries>
>> </ChartData>
>> <CategoryAxis>
>> <Axis>
>> <Title />
>> <MajorGridLines>
>> <Style>
>> <BorderStyle>
>> <Default>Solid</Default>
>> </BorderStyle>
>> </Style>
>> </MajorGridLines>
>> <MinorGridLines>
>> <Style>
>> <BorderStyle>
>> <Default>Solid</Default>
>> </BorderStyle>
>> </Style>
>> </MinorGridLines>
>> <Min>0</Min>
>> </Axis>
>> </CategoryAxis>
>> <DataSetName>DataSet1</DataSetName>
>> <PointWidth>0</PointWidth>
>> <Type>Bar</Type>
>> <Top>0.25in</Top>
>> <Title>
>> <Caption>USA</Caption>
>> </Title>
>> <Width>6in</Width>
>> <Height>2.5in</Height>
>> <SeriesGroupings>
>> <SeriesGrouping>
>> <DynamicSeries>
>> <Grouping Name="chart1_SeriesGroup1">
>> <GroupExpressions>
>> <GroupExpression>=Fields!CategoryName.Value</GroupExpression>
>> </GroupExpressions>
>> </Grouping>
>> <Sorting>
>> <SortBy>
>> <SortExpression>=Fields!CategoryName.Value</SortExpression>
>> <Direction>Ascending</Direction>
>> </SortBy>
>> </Sorting>
>> <Label>=Fields!CategoryName.Value</Label>
>> </DynamicSeries>
>> </SeriesGrouping>
>> </SeriesGroupings>
>> <Subtype>Plain</Subtype>
>> <PlotArea>
>> <Style>
>> <BackgroundColor>LightGrey</BackgroundColor>
>> <BorderStyle>
>> <Default>Solid</Default>
>> </BorderStyle>
>> </Style>
>> </PlotArea>
>> <Filters>
>> <Filter>
>> <FilterExpression>=Fields!Country.Value</FilterExpression>
>> <Operator>Equal</Operator>
>> <FilterValues>
>> <FilterValue>USA</FilterValue>
>> </FilterValues>
>> </Filter>
>> </Filters>
>> <Left>0.125in</Left>
>> <ValueAxis>
>> <Axis>
>> <Title />
>> <MajorGridLines>
>> <ShowGridLines>true</ShowGridLines>
>> <Style>
>> <BorderStyle>
>> <Default>Solid</Default>
>> </BorderStyle>
>> </Style>
>> </MajorGridLines>|||I used the code off the site I had to change the Private to Public because I
was getting errors and the only way I got them to go away was to change
Private to Public.
The code I have in the report properties code tab is as follows:
Public colorPalette As String() = {"Green", "Blue", "Red", "Orange", "Aqua",
"Teal", "Gold", "RoyalBlue", "#A59D93", "#B8341B", "#352F26", "#F1E7D6",
"#E16C56", "#CFBA9B"}
Public count As Integer = 0
Public mapping As New System.Collections.Hashtable()
Public Function GetColor(ByVal groupingValue As String) As String
If mapping.ContainsKey(groupingValue) Then
Return mapping(groupingValue)
End If
Dim c As String = colorPalette(count Mod colorPalette.Length)
count = count + 1
mapping.Add(groupingValue, c)
Return c
End Function
The Data field for my chart is: YTD
The Series field is: Project_Category
for the Data field properties on my Pie chart I went to the apperance tab
then series style... on the fill tab, color field I put the following FX:
=Code.GetColor(Fields!Project_Category.Value)
Any ideas what I am missing?
I also tried the following code that someone modified off your code example
with no luck either...
In Chart Properties, Data, Values, Edit, Appearance, Series Style I use this
function:
= Code.GetColor(Fields!Project_Category.Value)
And in the code for the report I have:
Public Function GetColor(ByVal Project_Category As String) As String
if Project_Category = "Value 1" Then
Return "#CC3333" ' "Red"
end if
if Project_Category = "Value 2" Then
Return "Pink"
end if
if Project_Category = "Value 3" Then
Return "#3300CC" ' "Blue"
end if
if (Project_Category <> "Value 1") and (Project_Category <> "Value 2") and
(Project_Category
<> "Project_Category") Then
Return "Black"
end if
End Function
again no luck with this one.....
THANKS AGAIN FOR ALL THE HELP!!!
"Robert Bruckner [MSFT]" wrote:
> Did you try the sample I had attached to the bottom of my previous posting,
> or did you download the other sample about custom legends from the blog
> article? Both should work as provided.
> In your particular case, the error message would indicate that you are
> missing the Function keyword for the corresponding End Function statement on
> line 14 of the custom code window of the report (VS menu -> report -> report
> properties -> custom code)
> -- Robert
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> "anthonysjo" <anthonysjo@.discussions.microsoft.com> wrote in message
> news:13337779-49F4-44A7-B0B8-4963E58D2B75@.microsoft.com...
> >I tried the code in the article but get the following error:
> >
> > There is an error on line 14 of custom code: [BC30430] 'End Function' must
> > be preceded by a matching 'Function'.
> > Build complete -- 1 errors, 0 warnings
> >
> >
> > Any ideas?
> >
> > "Robert Bruckner [MSFT]" wrote:
> >
> >> I suggest to follow the approach discussed in this blog article:
> >> http://blogs.msdn.com/bwelcker/archive/2005/05/20/420349.aspx
> >>
> >> You don't need the part about the custom legend, but you should take a
> >> close
> >> look at the custom color part of the sample. You can modify the code so
> >> that
> >> instead of having the hashtable approach to apply unique colors for
> >> categories, you replace it with some IF statement to explicitly control
> >> colors.
> >>
> >> A trivial RDL sample with two charts using different filters but sharing
> >> the
> >> same colors for categories is copied to the bottom of this posting.
> >>
> >> -- Robert
> >> This posting is provided "AS IS" with no warranties, and confers no
> >> rights.
> >>
> >>
> >> "anthonysjo" <anthonysjo@.discussions.microsoft.com> wrote in message
> >> news:69E297FD-F5C7-44D4-9463-5E4871B1CEAB@.microsoft.com...
> >> > Hello all!!
> >> >
> >> > I have created a pie chart that is embedded in a matrix report,
> >> > therefore
> >> > creating a new pie for every row. The problem I am having is the pie
> >> > slice
> >> > for the same series is changing each time there is a new pie. For
> >> > example,
> >> > in the first pie Cars may be designated as green but in the second pie
> >> > it
> >> > may
> >> > be red. I would like the colors to be consistent; all cars are
> >> > represented
> >> > as green slices. Oh and if there are no cars don't use the color green
> >> > for
> >> > another slice.
> >> >
> >> > I think this can be done using a nested expression but I am unsure how
> >> > to
> >> > write it...I either need an example of an expression that can handle
> >> > multiple slices or another way to handle the issue.
> >> >
> >> > Thanks,
> >> > Anthony
> >>
> >>
> >> ============================================> >>
> >> <?xml version="1.0" encoding="utf-8"?>
> >> <Report
> >> xmlns="http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefinition"
> >> xmlns:rd="">http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
> >> <RightMargin>1in</RightMargin>
> >> <Author>Robert M. Bruckner</Author>
> >> <Body>
> >> <ReportItems>
> >> <Chart Name="chart2">
> >> <ThreeDProperties>
> >> <Rotation>30</Rotation>
> >> <Inclination>30</Inclination>
> >> <Shading>Simple</Shading>
> >> <WallThickness>50</WallThickness>
> >> </ThreeDProperties>
> >> <ZIndex>1</ZIndex>
> >> <Style>
> >> <BackgroundColor>White</BackgroundColor>
> >> </Style>
> >> <Legend>
> >> <Visible>true</Visible>
> >> <Style>
> >> <BorderStyle>
> >> <Default>Solid</Default>
> >> </BorderStyle>
> >> </Style>
> >> <Position>RightCenter</Position>
> >> </Legend>
> >> <Palette>Default</Palette>
> >> <ChartData>
> >> <ChartSeries>
> >> <DataPoints>
> >> <DataPoint>
> >> <DataValues>
> >> <DataValue>
> >> <Value>=Sum(Fields!UnitsInStock.Value)</Value>
> >> </DataValue>
> >> </DataValues>
> >> <DataLabel />
> >> <Style>
> >>
> >> <BackgroundColor>=Code.GetColor(Fields!CategoryName.Value)</BackgroundColor>
> >> </Style>
> >> <Marker>
> >> <Size>6pt</Size>
> >> </Marker>
> >> </DataPoint>
> >> </DataPoints>
> >> </ChartSeries>
> >> </ChartData>
> >> <CategoryAxis>
> >> <Axis>
> >> <Title />
> >> <MajorGridLines>
> >> <Style>
> >> <BorderStyle>
> >> <Default>Solid</Default>
> >> </BorderStyle>
> >> </Style>
> >> </MajorGridLines>
> >> <MinorGridLines>
> >> <Style>
> >> <BorderStyle>
> >> <Default>Solid</Default>
> >> </BorderStyle>
> >> </Style>
> >> </MinorGridLines>
> >> <Min>0</Min>
> >> </Axis>
> >> </CategoryAxis>
> >> <DataSetName>DataSet1</DataSetName>
> >> <PointWidth>0</PointWidth>
> >> <Type>Bar</Type>
> >> <Top>3.125in</Top>
> >> <Title>
> >> <Caption>UK</Caption>
> >> </Title>
> >> <Width>6in</Width>
> >> <SeriesGroupings>
> >> <SeriesGrouping>
> >> <DynamicSeries>
> >> <Grouping Name="chart2_SeriesGroup1">
> >> <GroupExpressions>
> >>
> >> <GroupExpression>=Fields!CategoryName.Value</GroupExpression>
> >> </GroupExpressions>
> >> </Grouping>
> >> <Sorting>
> >> <SortBy>
> >>
> >> <SortExpression>=Fields!CategoryName.Value</SortExpression>
> >> <Direction>Ascending</Direction>
> >> </SortBy>
> >> </Sorting>
> >> <Label>=Fields!CategoryName.Value</Label>
> >> </DynamicSeries>
> >> </SeriesGrouping>
> >> </SeriesGroupings>
> >> <Subtype>Plain</Subtype>
> >> <PlotArea>
> >> <Style>
> >> <BackgroundColor>LightGrey</BackgroundColor>
> >> <BorderStyle>
> >> <Default>Solid</Default>
> >> </BorderStyle>
> >> </Style>
> >> </PlotArea>
> >> <Filters>
> >> <Filter>
> >> <FilterExpression>=Fields!Country.Value</FilterExpression>
> >> <Operator>Equal</Operator>
> >> <FilterValues>
> >> <FilterValue>UK</FilterValue>
> >> </FilterValues>
> >> </Filter>
> >> </Filters>
> >> <Left>0.125in</Left>
> >> <ValueAxis>
> >> <Axis>
> >> <Title />
> >> <MajorGridLines>
> >> <ShowGridLines>true</ShowGridLines>
> >> <Style>
> >> <BorderStyle>
> >> <Default>Solid</Default>
> >> </BorderStyle>
> >> </Style>
> >> </MajorGridLines>
> >> <MinorGridLines>
> >> <Style>
> >> <BorderStyle>
> >> <Default>Solid</Default>
> >> </BorderStyle>
> >> </Style>
> >> </MinorGridLines>
> >> <MajorTickMarks>Outside</MajorTickMarks>
> >> <Min>0</Min>
> >> <Margin>true</Margin>
> >> <Visible>true</Visible>
> >> <Scalar>true</Scalar>
> >> </Axis>
> >> </ValueAxis>
> >> </Chart>
> >> <Chart Name="chart1">
> >> <ThreeDProperties>
> >> <Rotation>30</Rotation>
> >> <Inclination>30</Inclination>
> >> <Shading>Simple</Shading>
> >> <WallThickness>50</WallThickness>
> >> </ThreeDProperties>
> >> <Style>
> >> <BackgroundColor>White</BackgroundColor>
> >> </Style>
> >> <Legend>
> >> <Visible>true</Visible>
> >> <Style>
> >> <BorderStyle>
> >> <Default>Solid</Default>
> >> </BorderStyle>
> >> </Style>
> >> <Position>RightCenter</Position>
> >> </Legend>
> >> <Palette>Default</Palette>
> >> <ChartData>
> >> <ChartSeries>
> >> <DataPoints>
> >> <DataPoint>
> >> <DataValues>
> >> <DataValue>
> >> <Value>=Sum(Fields!UnitsInStock.Value)</Value>
> >> </DataValue>
> >> </DataValues>
> >> <DataLabel />
> >> <Style>
> >>
> >> <BackgroundColor>=Code.GetColor(Fields!CategoryName.Value)</BackgroundColor>
> >> </Style>
> >> <Marker>
> >> <Size>6pt</Size>
> >> </Marker>
> >> </DataPoint>
> >> </DataPoints>
> >> </ChartSeries>
> >> </ChartData>
> >> <CategoryAxis>
> >> <Axis>
> >> <Title />
> >> <MajorGridLines>
> >> <Style>
> >> <BorderStyle>
> >> <Default>Solid</Default>
> >> </BorderStyle>
> >> </Style>
> >> </MajorGridLines>
> >> <MinorGridLines>
> >> <Style>
> >> <BorderStyle>
> >> <Default>Solid</Default>
> >> </BorderStyle>
> >> </Style>
> >> </MinorGridLines>
> >> <Min>0</Min>
> >> </Axis>
> >> </CategoryAxis>
> >> <DataSetName>DataSet1</DataSetName>
> >> <PointWidth>0</PointWidth>
> >> <Type>Bar</Type>
> >> <Top>0.25in</Top>
> >> <Title>
> >> <Caption>USA</Caption>
> >> </Title>
> >> <Width>6in</Width>
> >> <Height>2.5in</Height>
> >> <SeriesGroupings>
> >> <SeriesGrouping>
> >> <DynamicSeries>
> >> <Grouping Name="chart1_SeriesGroup1">
> >> <GroupExpressions>
> >>
> >> <GroupExpression>=Fields!CategoryName.Value</GroupExpression>
> >> </GroupExpressions>
> >> </Grouping>
> >> <Sorting>|||Robert,
I found the problem with the code that I got from your blog article....in
all the cutting and pasting I ended up with a second end function that I
needed to scroll down to see.
Good thing is that the code is working...bad thing is I am getting the same
results. What I am trying to do is almost like conditional formatting. If
you return a specific value I want to return a specific color, the next value
will have another color assigned, and so on. All in all I should have no
more than 5-6 values that I need to define colors for.
I tried the following code which I think is more like what I am wanting:
In Chart Properties, Data, Values, Edit, Appearance, Series Style I use this
function:
= Code.GetColor(Fields!Project_Category.Value)
And in the code for the report I have:
Public Function GetColor(ByVal Project_Category As String) As String
if Project_Category = "Value 1" Then
Return "#CC3333" ' "Red"
end if
if Project_Category = "Value 2" Then
Return "Pink"
end if
if Project_Category = "Value 3" Then
Return "#3300CC" ' "Blue"
end if
if (Project_Category <> "Value 1") and (Project_Category <> "Value 2") and
(Project_Category
<> "Value 3") Then
Return "Black"
end if
End Function
However, as I stated below I can't seem to get it to work because of the
following error:
There is an error on line 10 of custom code: [BC30201] Expression expected.
Build complete -- 1 errors, 0 warnings
I also thought of writing an IIF but I think the nesting could get pretty
complex....
"anthonysjo" wrote:
> I used the code off the site I had to change the Private to Public because I
> was getting errors and the only way I got them to go away was to change
> Private to Public.
> The code I have in the report properties code tab is as follows:
> Public colorPalette As String() = {"Green", "Blue", "Red", "Orange", "Aqua",
> "Teal", "Gold", "RoyalBlue", "#A59D93", "#B8341B", "#352F26", "#F1E7D6",
> "#E16C56", "#CFBA9B"}
> Public count As Integer = 0
> Public mapping As New System.Collections.Hashtable()
> Public Function GetColor(ByVal groupingValue As String) As String
> If mapping.ContainsKey(groupingValue) Then
> Return mapping(groupingValue)
> End If
> Dim c As String = colorPalette(count Mod colorPalette.Length)
> count = count + 1
> mapping.Add(groupingValue, c)
> Return c
> End Function
> The Data field for my chart is: YTD
> The Series field is: Project_Category
> for the Data field properties on my Pie chart I went to the apperance tab
> then series style... on the fill tab, color field I put the following FX:
> =Code.GetColor(Fields!Project_Category.Value)
> Any ideas what I am missing?
> I also tried the following code that someone modified off your code example
> with no luck either...
> In Chart Properties, Data, Values, Edit, Appearance, Series Style I use this
> function:
> = Code.GetColor(Fields!Project_Category.Value)
> And in the code for the report I have:
> Public Function GetColor(ByVal Project_Category As String) As String
> if Project_Category = "Value 1" Then
> Return "#CC3333" ' "Red"
> end if
> if Project_Category = "Value 2" Then
> Return "Pink"
> end if
> if Project_Category = "Value 3" Then
> Return "#3300CC" ' "Blue"
> end if
> if (Project_Category <> "Value 1") and (Project_Category <> "Value 2") and
> (Project_Category
> <> "Project_Category") Then
> Return "Black"
> end if
> End Function
> again no luck with this one.....
> THANKS AGAIN FOR ALL THE HELP!!!
> "Robert Bruckner [MSFT]" wrote:
> > Did you try the sample I had attached to the bottom of my previous posting,
> > or did you download the other sample about custom legends from the blog
> > article? Both should work as provided.
> >
> > In your particular case, the error message would indicate that you are
> > missing the Function keyword for the corresponding End Function statement on
> > line 14 of the custom code window of the report (VS menu -> report -> report
> > properties -> custom code)
> >
> > -- Robert
> > This posting is provided "AS IS" with no warranties, and confers no rights.
> >
> >
> >
> > "anthonysjo" <anthonysjo@.discussions.microsoft.com> wrote in message
> > news:13337779-49F4-44A7-B0B8-4963E58D2B75@.microsoft.com...
> > >I tried the code in the article but get the following error:
> > >
> > > There is an error on line 14 of custom code: [BC30430] 'End Function' must
> > > be preceded by a matching 'Function'.
> > > Build complete -- 1 errors, 0 warnings
> > >
> > >
> > > Any ideas?
> > >
> > > "Robert Bruckner [MSFT]" wrote:
> > >
> > >> I suggest to follow the approach discussed in this blog article:
> > >> http://blogs.msdn.com/bwelcker/archive/2005/05/20/420349.aspx
> > >>
> > >> You don't need the part about the custom legend, but you should take a
> > >> close
> > >> look at the custom color part of the sample. You can modify the code so
> > >> that
> > >> instead of having the hashtable approach to apply unique colors for
> > >> categories, you replace it with some IF statement to explicitly control
> > >> colors.
> > >>
> > >> A trivial RDL sample with two charts using different filters but sharing
> > >> the
> > >> same colors for categories is copied to the bottom of this posting.
> > >>
> > >> -- Robert
> > >> This posting is provided "AS IS" with no warranties, and confers no
> > >> rights.
> > >>
> > >>
> > >> "anthonysjo" <anthonysjo@.discussions.microsoft.com> wrote in message
> > >> news:69E297FD-F5C7-44D4-9463-5E4871B1CEAB@.microsoft.com...
> > >> > Hello all!!
> > >> >
> > >> > I have created a pie chart that is embedded in a matrix report,
> > >> > therefore
> > >> > creating a new pie for every row. The problem I am having is the pie
> > >> > slice
> > >> > for the same series is changing each time there is a new pie. For
> > >> > example,
> > >> > in the first pie Cars may be designated as green but in the second pie
> > >> > it
> > >> > may
> > >> > be red. I would like the colors to be consistent; all cars are
> > >> > represented
> > >> > as green slices. Oh and if there are no cars don't use the color green
> > >> > for
> > >> > another slice.
> > >> >
> > >> > I think this can be done using a nested expression but I am unsure how
> > >> > to
> > >> > write it...I either need an example of an expression that can handle
> > >> > multiple slices or another way to handle the issue.
> > >> >
> > >> > Thanks,
> > >> > Anthony
> > >>
> > >>
> > >> ============================================> > >>
> > >> <?xml version="1.0" encoding="utf-8"?>
> > >> <Report
> > >> xmlns="http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefinition"
> > >> xmlns:rd="">http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
> > >> <RightMargin>1in</RightMargin>
> > >> <Author>Robert M. Bruckner</Author>
> > >> <Body>
> > >> <ReportItems>
> > >> <Chart Name="chart2">
> > >> <ThreeDProperties>
> > >> <Rotation>30</Rotation>
> > >> <Inclination>30</Inclination>
> > >> <Shading>Simple</Shading>
> > >> <WallThickness>50</WallThickness>
> > >> </ThreeDProperties>
> > >> <ZIndex>1</ZIndex>
> > >> <Style>
> > >> <BackgroundColor>White</BackgroundColor>
> > >> </Style>
> > >> <Legend>
> > >> <Visible>true</Visible>
> > >> <Style>
> > >> <BorderStyle>
> > >> <Default>Solid</Default>
> > >> </BorderStyle>
> > >> </Style>
> > >> <Position>RightCenter</Position>
> > >> </Legend>
> > >> <Palette>Default</Palette>
> > >> <ChartData>
> > >> <ChartSeries>
> > >> <DataPoints>
> > >> <DataPoint>
> > >> <DataValues>
> > >> <DataValue>
> > >> <Value>=Sum(Fields!UnitsInStock.Value)</Value>
> > >> </DataValue>
> > >> </DataValues>
> > >> <DataLabel />
> > >> <Style>
> > >>
> > >> <BackgroundColor>=Code.GetColor(Fields!CategoryName.Value)</BackgroundColor>
> > >> </Style>
> > >> <Marker>
> > >> <Size>6pt</Size>
> > >> </Marker>
> > >> </DataPoint>
> > >> </DataPoints>
> > >> </ChartSeries>
> > >> </ChartData>
> > >> <CategoryAxis>
> > >> <Axis>
> > >> <Title />
> > >> <MajorGridLines>
> > >> <Style>
> > >> <BorderStyle>
> > >> <Default>Solid</Default>
> > >> </BorderStyle>
> > >> </Style>
> > >> </MajorGridLines>
> > >> <MinorGridLines>
> > >> <Style>
> > >> <BorderStyle>
> > >> <Default>Solid</Default>
> > >> </BorderStyle>
> > >> </Style>
> > >> </MinorGridLines>
> > >> <Min>0</Min>
> > >> </Axis>
> > >> </CategoryAxis>
> > >> <DataSetName>DataSet1</DataSetName>
> > >> <PointWidth>0</PointWidth>
> > >> <Type>Bar</Type>
> > >> <Top>3.125in</Top>
> > >> <Title>
> > >> <Caption>UK</Caption>
> > >> </Title>
> > >> <Width>6in</Width>
> > >> <SeriesGroupings>
> > >> <SeriesGrouping>
> > >> <DynamicSeries>
> > >> <Grouping Name="chart2_SeriesGroup1">
> > >> <GroupExpressions>
> > >>
> > >> <GroupExpression>=Fields!CategoryName.Value</GroupExpression>
> > >> </GroupExpressions>
> > >> </Grouping>
> > >> <Sorting>
> > >> <SortBy>
> > >>
> > >> <SortExpression>=Fields!CategoryName.Value</SortExpression>
> > >> <Direction>Ascending</Direction>
> > >> </SortBy>
> > >> </Sorting>
> > >> <Label>=Fields!CategoryName.Value</Label>
> > >> </DynamicSeries>
> > >> </SeriesGrouping>
> > >> </SeriesGroupings>
> > >> <Subtype>Plain</Subtype>
> > >> <PlotArea>
> > >> <Style>
> > >> <BackgroundColor>LightGrey</BackgroundColor>
> > >> <BorderStyle>
> > >> <Default>Solid</Default>
> > >> </BorderStyle>
> > >> </Style>
> > >> </PlotArea>
> > >> <Filters>
> > >> <Filter>
> > >> <FilterExpression>=Fields!Country.Value</FilterExpression>
> > >> <Operator>Equal</Operator>
> > >> <FilterValues>
> > >> <FilterValue>UK</FilterValue>
> > >> </FilterValues>
> > >> </Filter>
> > >> </Filters>
> > >> <Left>0.125in</Left>
> > >> <ValueAxis>
> > >> <Axis>
> > >> <Title />
> > >> <MajorGridLines>
> > >> <ShowGridLines>true</ShowGridLines>
> > >> <Style>
> > >> <BorderStyle>
> > >> <Default>Solid</Default>
> > >> </BorderStyle>
> > >> </Style>
> > >> </MajorGridLines>
> > >> <MinorGridLines>
> > >> <Style>
> > >> <BorderStyle>
> > >> <Default>Solid</Default>
> > >> </BorderStyle>
> > >> </Style>
> > >> </MinorGridLines>
> > >> <MajorTickMarks>Outside</MajorTickMarks>
> > >> <Min>0</Min>
> > >> <Margin>true</Margin>
> > >> <Visible>true</Visible>
> > >> <Scalar>true</Scalar>
> > >> </Axis>
> > >> </ValueAxis>
> > >> </Chart>
> > >> <Chart Name="chart1">
> > >> <ThreeDProperties>
> > >> <Rotation>30</Rotation>
> > >> <Inclination>30</Inclination>
> > >> <Shading>Simple</Shading>
> > >> <WallThickness>50</WallThickness>
> > >> </ThreeDProperties>
> > >> <Style>
> > >> <BackgroundColor>White</BackgroundColor>
> > >> </Style>
> > >> <Legend>
> > >> <Visible>true</Visible>
> > >> <Style>
> > >> <BorderStyle>
> > >> <Default>Solid</Default>
> > >> </BorderStyle>
> > >> </Style>|||All is well!!! I took the following code:
= Code.GetColor(Fields!Project_Category.Value)
> And in the code for the report I have:
> Public Function GetColor(ByVal Project_Category As String) As String
> if Project_Category = "Value 1" Then
> Return "#CC3333" ' "Red"
> end if
> if Project_Category = "Value 2" Then
> Return "Pink"
> end if
> if Project_Category = "Value 3" Then
> Return "#3300CC" ' "Blue"
> end if
> if (Project_Category <> "Value 1") and (Project_Category <> "Value 2") and
> (Project_Category
> <> "Value 3") Then
> Return "Black"
> end if
> End Function
Then removed this....
if (Project_Category <> "Value 1") and (Project_Category <> "Value 2") and
> (Project_Category
> <> "Value 3") Then
> Return "Black"
> end if
Everything works great now!!!!
Thanks for all the help!!
"anthonysjo" wrote:
> Robert,
> I found the problem with the code that I got from your blog article....in
> all the cutting and pasting I ended up with a second end function that I
> needed to scroll down to see.
> Good thing is that the code is working...bad thing is I am getting the same
> results. What I am trying to do is almost like conditional formatting. If
> you return a specific value I want to return a specific color, the next value
> will have another color assigned, and so on. All in all I should have no
> more than 5-6 values that I need to define colors for.
> I tried the following code which I think is more like what I am wanting:
> In Chart Properties, Data, Values, Edit, Appearance, Series Style I use this
> function:
> = Code.GetColor(Fields!Project_Category.Value)
> And in the code for the report I have:
> Public Function GetColor(ByVal Project_Category As String) As String
> if Project_Category = "Value 1" Then
> Return "#CC3333" ' "Red"
> end if
> if Project_Category = "Value 2" Then
> Return "Pink"
> end if
> if Project_Category = "Value 3" Then
> Return "#3300CC" ' "Blue"
> end if
> if (Project_Category <> "Value 1") and (Project_Category <> "Value 2") and
> (Project_Category
> <> "Value 3") Then
> Return "Black"
> end if
> End Function
> However, as I stated below I can't seem to get it to work because of the
> following error:
> There is an error on line 10 of custom code: [BC30201] Expression expected.
> Build complete -- 1 errors, 0 warnings
> I also thought of writing an IIF but I think the nesting could get pretty
> complex....
> "anthonysjo" wrote:
> > I used the code off the site I had to change the Private to Public because I
> > was getting errors and the only way I got them to go away was to change
> > Private to Public.
> >
> > The code I have in the report properties code tab is as follows:
> > Public colorPalette As String() = {"Green", "Blue", "Red", "Orange", "Aqua",
> > "Teal", "Gold", "RoyalBlue", "#A59D93", "#B8341B", "#352F26", "#F1E7D6",
> > "#E16C56", "#CFBA9B"}
> > Public count As Integer = 0
> > Public mapping As New System.Collections.Hashtable()
> >
> > Public Function GetColor(ByVal groupingValue As String) As String
> > If mapping.ContainsKey(groupingValue) Then
> > Return mapping(groupingValue)
> > End If
> > Dim c As String = colorPalette(count Mod colorPalette.Length)
> > count = count + 1
> > mapping.Add(groupingValue, c)
> > Return c
> > End Function
> >
> > The Data field for my chart is: YTD
> > The Series field is: Project_Category
> >
> > for the Data field properties on my Pie chart I went to the apperance tab
> > then series style... on the fill tab, color field I put the following FX:
> > =Code.GetColor(Fields!Project_Category.Value)
> >
> > Any ideas what I am missing?
> >
> > I also tried the following code that someone modified off your code example
> > with no luck either...
> >
> > In Chart Properties, Data, Values, Edit, Appearance, Series Style I use this
> > function:
> >
> > = Code.GetColor(Fields!Project_Category.Value)
> >
> > And in the code for the report I have:
> >
> > Public Function GetColor(ByVal Project_Category As String) As String
> > if Project_Category = "Value 1" Then
> > Return "#CC3333" ' "Red"
> > end if
> > if Project_Category = "Value 2" Then
> > Return "Pink"
> > end if
> > if Project_Category = "Value 3" Then
> > Return "#3300CC" ' "Blue"
> > end if
> > if (Project_Category <> "Value 1") and (Project_Category <> "Value 2") and
> > (Project_Category
> > <> "Project_Category") Then
> > Return "Black"
> > end if
> > End Function
> >
> > again no luck with this one.....
> >
> > THANKS AGAIN FOR ALL THE HELP!!!
> >
> > "Robert Bruckner [MSFT]" wrote:
> >
> > > Did you try the sample I had attached to the bottom of my previous posting,
> > > or did you download the other sample about custom legends from the blog
> > > article? Both should work as provided.
> > >
> > > In your particular case, the error message would indicate that you are
> > > missing the Function keyword for the corresponding End Function statement on
> > > line 14 of the custom code window of the report (VS menu -> report -> report
> > > properties -> custom code)
> > >
> > > -- Robert
> > > This posting is provided "AS IS" with no warranties, and confers no rights.
> > >
> > >
> > >
> > > "anthonysjo" <anthonysjo@.discussions.microsoft.com> wrote in message
> > > news:13337779-49F4-44A7-B0B8-4963E58D2B75@.microsoft.com...
> > > >I tried the code in the article but get the following error:
> > > >
> > > > There is an error on line 14 of custom code: [BC30430] 'End Function' must
> > > > be preceded by a matching 'Function'.
> > > > Build complete -- 1 errors, 0 warnings
> > > >
> > > >
> > > > Any ideas?
> > > >
> > > > "Robert Bruckner [MSFT]" wrote:
> > > >
> > > >> I suggest to follow the approach discussed in this blog article:
> > > >> http://blogs.msdn.com/bwelcker/archive/2005/05/20/420349.aspx
> > > >>
> > > >> You don't need the part about the custom legend, but you should take a
> > > >> close
> > > >> look at the custom color part of the sample. You can modify the code so
> > > >> that
> > > >> instead of having the hashtable approach to apply unique colors for
> > > >> categories, you replace it with some IF statement to explicitly control
> > > >> colors.
> > > >>
> > > >> A trivial RDL sample with two charts using different filters but sharing
> > > >> the
> > > >> same colors for categories is copied to the bottom of this posting.
> > > >>
> > > >> -- Robert
> > > >> This posting is provided "AS IS" with no warranties, and confers no
> > > >> rights.
> > > >>
> > > >>
> > > >> "anthonysjo" <anthonysjo@.discussions.microsoft.com> wrote in message
> > > >> news:69E297FD-F5C7-44D4-9463-5E4871B1CEAB@.microsoft.com...
> > > >> > Hello all!!
> > > >> >
> > > >> > I have created a pie chart that is embedded in a matrix report,
> > > >> > therefore
> > > >> > creating a new pie for every row. The problem I am having is the pie
> > > >> > slice
> > > >> > for the same series is changing each time there is a new pie. For
> > > >> > example,
> > > >> > in the first pie Cars may be designated as green but in the second pie
> > > >> > it
> > > >> > may
> > > >> > be red. I would like the colors to be consistent; all cars are
> > > >> > represented
> > > >> > as green slices. Oh and if there are no cars don't use the color green
> > > >> > for
> > > >> > another slice.
> > > >> >
> > > >> > I think this can be done using a nested expression but I am unsure how
> > > >> > to
> > > >> > write it...I either need an example of an expression that can handle
> > > >> > multiple slices or another way to handle the issue.
> > > >> >
> > > >> > Thanks,
> > > >> > Anthony
> > > >>
> > > >>
> > > >> ============================================> > > >>
> > > >> <?xml version="1.0" encoding="utf-8"?>
> > > >> <Report
> > > >> xmlns="http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefinition"
> > > >> xmlns:rd="">http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
> > > >> <RightMargin>1in</RightMargin>
> > > >> <Author>Robert M. Bruckner</Author>
> > > >> <Body>
> > > >> <ReportItems>
> > > >> <Chart Name="chart2">
> > > >> <ThreeDProperties>
> > > >> <Rotation>30</Rotation>
> > > >> <Inclination>30</Inclination>
> > > >> <Shading>Simple</Shading>
> > > >> <WallThickness>50</WallThickness>
> > > >> </ThreeDProperties>
> > > >> <ZIndex>1</ZIndex>
> > > >> <Style>
> > > >> <BackgroundColor>White</BackgroundColor>
> > > >> </Style>
> > > >> <Legend>
> > > >> <Visible>true</Visible>
> > > >> <Style>
> > > >> <BorderStyle>
> > > >> <Default>Solid</Default>
> > > >> </BorderStyle>
> > > >> </Style>
> > > >> <Position>RightCenter</Position>
> > > >> </Legend>
> > > >> <Palette>Default</Palette>
> > > >> <ChartData>
> > > >> <ChartSeries>
> > > >> <DataPoints>
> > > >> <DataPoint>
> > > >> <DataValues>
> > > >> <DataValue>
> > > >> <Value>=Sum(Fields!UnitsInStock.Value)</Value>
> > > >> </DataValue>
> > > >> </DataValues>
> > > >> <DataLabel />
> > > >> <Style>
> > > >>
> > > >> <BackgroundColor>=Code.GetColor(Fields!CategoryName.Value)</BackgroundColor>
> > > >> </Style>
> > > >> <Marker>
> > > >> <Size>6pt</Size>
> > > >> </Marker>
> > > >> </DataPoint>
> > > >> </DataPoints>
> > > >> </ChartSeries>
> > > >> </ChartData>
> > > >> <CategoryAxis>
> > > >> <Axis>
> > > >> <Title />
> > > >> <MajorGridLines>
> > > >> <Style>
> > > >> <BorderStyle>
> > > >> <Default>Solid</Default>
> > > >> </BorderStyle>
> > > >> </Style>
> > > >> </MajorGridLines>
> > > >> <MinorGridLines>
> > > >> <Style>
> > > >> <BorderStyle>
> > > >> <Default>Solid</Default>
> > > >> </BorderStyle>
> > > >> </Style>
> > > >> </MinorGridLines>
> > > >> <Min>0</Min>
> > > >> </Axis>
> > > >> </CategoryAxis>
> > > >> <DataSetName>DataSet1</DataSetName>
> > > >> <PointWidth>0</PointWidth>
> > > >> <Type>Bar</Type>
> > > >> <Top>3.125in</Top>
> > > >> <Title>
> > > >> <Caption>UK</Caption>
> > > >> </Title>
> > > >> <Width>6in</Width>
> > > >> <SeriesGroupings>
> > > >> <SeriesGrouping>
> > > >> <DynamicSeries>
> > > >> <Grouping Name="chart2_SeriesGroup1">
> > > >> <GroupExpressions>
> > > >>
> > > >> <GroupExpression>=Fields!CategoryName.Value</GroupExpression>
> > > >> </GroupExpressions>
> > > >> </Grouping>
> > > >> <Sorting>
> > > >> <SortBy>
> > > >>
> > > >> <SortExpression>=Fields!CategoryName.Value</SortExpression>
> > > >> <Direction>Ascending</Direction>
> > > >> </SortBy>
> > > >> </Sorting>
> > > >> <Label>=Fields!CategoryName.Value</Label>
> > > >> </DynamicSeries>
> > > >> </SeriesGrouping>
> > > >> </SeriesGroupings>
> > > >> <Subtype>Plain</Subtype>
> > > >> <PlotArea>
> > > >> <Style>
> > > >> <BackgroundColor>LightGrey</BackgroundColor>
> > > >> <BorderStyle>
> > > >> <Default>Solid</Default>
> > > >> </BorderStyle>
> > > >> </Style>
> > > >> </PlotArea>
> > > >> <Filters>
> > > >> <Filter>
> > > >> <FilterExpression>=Fields!Country.Value</FilterExpression>
> > > >> <Operator>Equal</Operator>