SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Syntax


Syntax

Author
Message
Tim Foster
Tim Foster
SSC Rookie
SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)

Group: General Forum Members
Points: 44 Visits: 114
Folks,

Can anyone see what's wrong with the following? It's been bugging me for ages as I can't see any problem withit.

=First(Fields("gradient_colour" & Fields!Response.Value).Value, "uspGetReportSettings")

This is setting the background colour of a textbox. The value in the text box is percentage from the dataset "feedbackResults", Response is a column from that dataset. uspReportSettings is a generic sp that returns all the report settings in a single row. In this instance, Response returns 5 and when I call:
=First(Fields("gradient_colour5", "uspGetReportSettings")
It works fine.
dohnfors
dohnfors
SSC Rookie
SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)

Group: General Forum Members
Points: 48 Visits: 188
Do you get any error-messages? Is the textbox stand-alone or part of a tablix?
Tim Foster
Tim Foster
SSC Rookie
SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)

Group: General Forum Members
Points: 44 Visits: 114
Hi dohnfors,

Yes, it's part of a tablix

The error is:
The BackgroundColor expression for the text box 'response_perc' referes to the field 'Response'. Report item expressions can only refer to fields within the current dataset scope or, if inside an aggregate, the specified dataset scope.

However the dataset for the tablix is the dataset containing the Response column. The tablix displays the percentages of each response and the response column is displayed within the tablix, so it's defo not out of scope.
dohnfors
dohnfors
SSC Rookie
SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)

Group: General Forum Members
Points: 48 Visits: 188
The problem is that the aggregate is bound to the dataset "uspGetReportSettings". Everything inside that aggregate (between the two parenthesis) is calculated with that scope and the field "Response" doesn't exists in that dataset.

I would try another approach based on this article http://blogs.msdn.com/b/bwelcker/archive/2007/07/11/laser-guided-missiles-report-localization-through-parameters.aspx.

1. Unpivot your dataset "uspGetReportSettings" so there is one row for each setting instead of one column:

Setting Value
gradient_colour1 Red
gradient_colour2 Blue
... ...

2. Create a hidden multivalued parameter based on that dataset with setting as label and Value as value. Set the default values to the same dataset and the Value field to 'Value'.

3. Copy and paste this code to custom code:

Public Function GetReportSetting(P as Parameter, Label as String) as String
Dim i As Integer
For i = 0 to Ubound(P.Value)
If (P.Label(i) = Label) Then Return P.Value(i)
Next i
Return Label
End Function

4. Use the code below to change the background color:

Code.GetReportSetting(Parameters!uspGetReportSettings, "gradient_colour" & Fields!Response.Value)

Check out the attached file for an example!
Attachments
Test.rdl.txt (3 views, 288.00 KB)
Tim Foster
Tim Foster
SSC Rookie
SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)

Group: General Forum Members
Points: 44 Visits: 114
Thanks dohnfors,

I hadn't realised that the scope of the aggregate would override in that context.

I understand your solution, I've used that method for internationalisation of text. I think in this case though, it would require an awful lot of changes to achieve a minimal gain. I can code around it with a switch statement for this particular issue. Definitely worth bearing in mind for the future though.

Thanks for your help.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search