Loop through the dataset and display the result in textbox SSRS - reporting-services

I have a Dataset for suppose consider it as CreditCards
CreditCards Dataset
-------------------------------------------------------|
Id Value
-------------------------------------------------------|
1 Amex
2 Discover
3 Citi
" ***** so on****
"
-------------------------------------------------------|
my report i need to loop through the whole dataset and have to print the like below
Amex(1), Discover(2), citi(3)
The dataset will take a multivalued parameter consider it as
id( 1,2,3)
How can i display the values in my report as
Amex(1), Discover(2), citi(3)
i tried this route, but didnt had any luck.
Any help would be appreciated
Thanks

Try to write expression for the textbox:
=(Field!Value.Value)+" ("+Cstr(Field!ID.Value)+")"

Related

SSRS - Use the result from one textbox to populate a field from a dataset

I am writing a report in SSRS. Can i use the text result from a textbox to pull a Field from one of my datasets?
For example:
In Textbox1, i have the formula =First(Fields!Metric1.Value, "Dataset2") which produces the text result: "BikeSales" in Textbox1
I need an expression in Textbox2 that references a Field called BikeSales in DataSet1 based on the result. Something like: =Sum(Fields.("Text from Textbox1").Value, "Dataset1") to pull the Field from Dataset 1.
Is this possible?
If all you want to do is reference the Textbox1 value.. you can use Reportitems!Textbox1.value
If you want the value from the actual dataset, you can use lookup

SSRS Dataset get a row based on specific criteria

I have a dataset called Box as below:
Dataset Called Box
I am trying to rewrite this Crystal Reports command If {Name} like "Train*" Then
{volume} in SSRS as =IIf(Fields!NAME.Value="Train", Fields!VOLUME.Value, Nothing) or =IIf(Left(Fields!NAME.Value,3)="Tra", Fields!VOLUME.Value, Nothing) I need to get the last value 9977, but I cannot use Last function in SSRS, as the order might change.
Please suggest.
Thanks.

SSRS IIF Expression across Multiple DataSets

I'm trying to do an IIF expression on a 2nd dataset to sum the 'BookingsComfirmed2016LASTWEEK' column and then divide it by the sum of the 'Stock2016Week' column in the dataset I'm in and where the PropertyTypeCategory = Cottage, but with no joy. I'm sure it's something to do with the placement of the 2nd dataset name, but would appreciate any help. Regards Claire
Dataset1 = TradingLastWeekandYTD
Dataset2 = TradinglastWeekandYTDSTOCK
=(IIF(Fields!PropertyTypeCategory.Value, "TradingLastWeekandYTD" = "Cottage",Sum(Fields!BookingsConfirmed2016LASTWEEK.Value, "TradingLastWeekandYTD")) /(IIF(Fields!PropertyTypeCategory.Value = "Cottage", Sum(Fields!Stock2016Week.Value)),0)
Your iif() won't work like this.
You can't check row by row in a dataset you're not currently working in, which is what you are trying to do with the first part of the iif().
You can use custom code to do an aggregated lookupset() to get the values of the first part.
This link https://itsalocke.com/aggregate-on-a-lookup-in-ssrs/ will help you do the custom code.
For the lookupset(), you would have to do something like..
=Code.SumLookup(lookupset(Fields!PropertyTypeCategory.Value, "Cottage", Fields!BookingsConfirmed2016LASTWEEK.Value))
This assumes that your custom code function is called "SumLookup". It will sum all the values that the lookupset() returns.

SSRS Tablix filter to exclude data from 1 dataset if its not in dataset 2

I am working on an report which has two slightly different data-sets (dataset 1 and dataset2). There are multiple tables within the report.
For the tablix that is using dataset 1, I would like to add a filter that would exclude deals from dataset 1 that are not in dataset 2. The common Id for these datasets would be Dealid.
What would this Filter expression look like? Any help would be immensely appreciated.
You can add a filter in your Dataset 1 or the Tablix and use the below expressions.
In Expression entry box use:
=IIF(
Isnothing(
Lookup(Fields!DealID.Value,Fields!DealID.Value,Fields!DealID.Value,"DataSet2")),
"Exclude","Include"
)
For the Value entry box use:
="Include"
It will exclude the rows where DealID in dataset 1 aren't present in dataset 2.
Let me know if this helps.

SSRS subreport with parameter rendering only one record of group

I want to build a report that returns records for a group of employees and by specific dates and supervisor, and renders the report by employee (as in a batch). I am doing this with a main report and 3 subreports. My subreports work individually and I just got one subreport to render from main but only the 1st record in the group displays.
Dataset on main has 3 parameters, USERID, BegDate, EndDate. Dataset on subreport take EMPID, BegDate, EndDate. I inserted subreport on main and subreport parameters as follows:
Name Value
CurEmp =First(Fields!EMPID.Value, "DataSet1")
BegDate [#BegDate]
EndDate [#EndDate]
Where CurEmp is used in the where clause of DataSet1/sql query i.e. WHERE EMPID = #CurEmp
Main report parameters in DataSet1 are:
Name Value
#USERID [#USERID]
#BegDate [#BegDate]
#EndDate [#EndDate]
Now I realize that the =First in the Expression in Value of parameter is supposed to render only the first record but nothing I change it to will render at all. I have done tutorials and googled for 2 days. I can get the simple subreports to work but nothing seems to apply to what I am trying to do. Can someone direct me to an example that applies to my situation?
BTW I have set my VS2008 environment to a Business Inteligence Project.
UPDATE: I have added my sql queries below to help explain per suggestion by #Sam. I actually was starting to look at the fact that maybe I am writing the queries wrong. I am confused about what the main report query should be compared to subquery....I hope this helps to clarify my meaning.
Main report dataset =
SELECT
v.EMPID,
UPPER(p.FirstName + ' ' + p.LastName) as EmpFullName,
v.dtmDate,
v.TCode,
v.Hours,
v.ProjectNo,
from vwPersonSummary v
join tblPerson t on v.EMPID = p.EMPID
WHERE v.USERID = #USERID --Supervisor’s EMPID
AND
v.dtmDate BETWEEN #BegDate AND #EndDate
ORDER BY v.EMPID, v.dtmDate
Subreport dataset=
SELECT
v.EMPID,
UPPER(p.FirstName + ' ' + p.LastName) as EmpFullName,
v.dtmDate,
v.Tcode,
v.Hours,
v.ProjectNo
from vwPersonSummary v
join tblPerson t on v. EMPID = t. EMPID
WHERE
v.EMPID = #CurEmp
AND v.dtmDate BETWEEN #BegDate AND #EndDate
ORDER BY v.dtmDate
So your fix/answer is going to be something like below.
When defining the the parameter from the main report it should be something like this.
=Join(LookupSet(1,1,Fields!EMPID.Value,"DataSet1"),",")
Once that is defined make sure that the sub report parameter Data Type is set as Text and Allow multiple values have been checked.
After that for the data set of the sub report don't set a where condition. Instead in Data Set properties go to Filters.
In Expression set something like
=CStr(Fields!EMPID.Value)
and set Operator as In and set the Value as something like below.
=Split(Parameters!EmpId.Value(0),",")
Well basically that's it. Hope this helps.