Solved

How do I use the InScope function in an expression of an RDL report?

Posted on 2009-05-08
6
1,575 Views
Last Modified: 2012-05-06
I am creating an RDL report, using SQL Server 2008.  

On my report, I need to display a constant list of interests. I need to identify within this constant list of interests which interests are "selected" or "chosen".  I currently have two seperate stored procedures set up, one to list all available interests, and another to list all the interests "selected" by a particular person.  I would like to re-use these 2 stored procedures, so I have set up 2 datasets in my report over these appropriate stored procedures, "AllInterests" (get all interests) and "EntityInterests" (get interests for a speicfic person).

I created a matrix table, with the dataset equal to "AllInterests". In a field in this table, I added an expression: =IIf(InScope("EntityInterests"), "Y", "N").  I was hoping that this would then put a "Y" in this field if the current "all interest" row in the table was included in the "EntityInterest" list; otherwise display a "N" in this field.

But this is not working; it is returning "N" for me all the time. Am I not using the InScope function properly? Or is there a better way to accomplish this without using the InScope function? I am very new to RDL reporting; this is acutally the first report i have ever created in RDL. Any suggestions would be appreciated.
0
Comment
Question by:farminsure
  • 2
  • 2
  • 2
6 Comments
 
LVL 37

Expert Comment

by:ValentinoV
Comment Utility
The report that you are creating, would it be specific for one person?  If so, "Person" should be a parameter of the report and you could then use that parameter to retrieve the selected person's interests.
How you set up the "Person" parameter would depend on your data and your business model.  If you're using the person's name to identify a person, that should be the label of the parameter.  And the value of the parameter should be the value that you need to look up a particular person's interests, the value that you need to provide to the EntityInterests stored proc.
0
 
LVL 37

Expert Comment

by:ValentinoV
Comment Utility
Here's some info on using parameters in Reporting Services: http://www.sql-server-performance.com/articles/reporting/report_parameters_p1.aspx
0
 
LVL 26

Accepted Solution

by:
Chris Luttrell earned 500 total points
Comment Utility
Sorry, but in short, Yes you are using the InScope function improperly.  It is used to indicate whether the current instance of an item is in the specified scope.  See http://msdn.microsoft.com/en-us/library/ms156490.aspx for what it is for.
From that site: "The following code example indicates whether the current instance of the item is in the Product dataset, data region, or group scope.  =InScope("Product") "
So your example is always returning "N" because where you are invoking it is not in the other Dataset's Scope, not because that value is not because the value is not in the other dataset.
I have seen many people want to merge datastes or lookup values of one from the other and I have not seen anyone who can hack that yet.  In the mean time you will have to combine the info into one dataset to be able to indicate the interest.  It should not be too hard to use what you have in your current stored procedures to give you what you need, but it will mean either changing what EntityInterests returns or making a new one that takes a person like EntityInterests but returns all Interests but with a flag for the interested ones.  If you need SP help I can provide that if you share some details.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:farminsure
Comment Utility
ValentinoV:  Yes, this report will be for one person at a time. But I am already passing in the desired person's ID as a parameter to the report. I am also successfully getting a list of interests for that person from my EntityInterests stored procedure. What I need to do though is combine the list specific to the one person with a list of all possible Interests. So there might be about 20 possible interests, but one person might have only choses "5" of those interests.
It's "combining" those pieces of information that I am having difficulties with; at least when using 2 stored procedures like I am doing.
It sounds as if I may have to create a new sproc to return the information I am wanting.  If you know of another method, please let me know; otherwise I will proceed with that method.
0
 

Author Comment

by:farminsure
Comment Utility
CGLuttrell:
Thanks, that helps me out. I do have a question regarding how to set up the sproc...
My "All possible interests" (Interests) table consists of 2 columns, an ID and a Description. A second table stores the interests that a specific person has selected: CustomerInterests. This table consists of a unique ID column, a FK to the InterestsID table, and a FK to the PersonID.
Is this enough info for you to provide an example of how to set up a sproc to return all records in the Interests file, with a "flag" indicating the records that match in CustomerInterests...
 
0
 
LVL 26

Assisted Solution

by:Chris Luttrell
Chris Luttrell earned 500 total points
Comment Utility
Create the sproc to pass in PersonID and use the query below to get your data.
select AI.Id, AI.Description, EI.PersonID

from AllInterest AI

Left Outer Join EntityInterest EI on AI.ID = EI.InterestID and EI.PersonID = @PersonID

Open in new window

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

How to increase the row limit in Jasper Server.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now