I have an SSRS Report using a Table.
You can select multiple Clients and Periods and for every pair there will be a row in the table. So 2 Clients * 3 Periods = 6 rows.
Now... there are some cells that are more complicated than having a single value and I want to place a subreport inside these cells. The Subreport will take the Client and Period for that particular Row as params.
This is where the issue comes in. The Parameters will not pass properly.
I can put Parameters!ClientID.Value(0) as an expression for example and it will pass the first ClientID properly but if I just put Parameters!ClientID.Value it breaks... And I want the Client/Period for the current row.
But how is it that I can't pass the params but CAN fill a new dataset for every row based on that Client/Period pair??
Note that I'd really prefer not to have to edit the SP that builds that dataset to return the Client/Period itself. Sure that would work.. but WHY would that be needed when I have the Parameters?
Any ideas? I'm doing this in a Visual Studio Report Project.
If I've understood correctly you don't need to use the parameter. You need to use the value of the field from the dataset. So if your table shows client and period then the parameter values passed in would be =Fields!Client.Value and =Fields!Period.Value
Client Period SubReportCell
Bob 2017 "subreport here passing in Bob, 2017"
Geoff 2015 "sub report here passing in Geoff, 2015"
You should just be able to choose these from the dropdown lists in the subreport setting dialogue box.
Related
I am writing an SSRS report in which I've a tablix that actually contain a subreport in one of its table cell. Now I want to understand to get this value as Sum on main report. For example, below is the student data:
Student Name | Total Subject | Obtained Marks (Sub Report)
XYZ | 6 | 35
ABC | 6 | 46
In above example, I am able to see the total marks of the first subject only. But I need to get the total form all 6 subjects from sub report. My tablix is already has Grouped by Student Name.
Below are the ways I tried to get it done:
Added another column in tablix and try to get the subreport as ReportItems! Subreport2, didn't work.
In the same column, I tried with Sum (Subreport2).
But since Subreport2 as report items are not accessible I'm not able to get it done.
UPDATE 1
I am using below expression to get sub-report value:
=ReportItems("Subreport2").value
The short answer is, no, you can't access fields from a subreport in the manner that you are attempting to. However, there is an easy way to get the values from that subreport that you may not have realized. The basic solution is to simply add another dataset to your report using the same query or stored procedure that is used in the subreport and getting the required data from that dataset. For example, you could then use a lookup function to match the data as needed. The lookup function requires four parameters detailed in the following expression.
= Lookup([SourceValue].Value, [DestinationValue].Value, [LookupValue].Value, "[DestinationDataset]")
The idea in your case would be to put your student name or ID field from the main report dataset in for source value, match that value in your subreport dataset for the destination value, get the value you need for lookup value, and the subreport dataset goes in parenthesis to indicate where to get the data from. So the following expression gives you an idea of what you need.
= Lookup(Fields!studentID.Value, Fields!studentIDSub.Value, Fields!ObtainedMarks.Value, "SubreportDataset")
Take a look at the documentation if you need any addition information.
I'm using Excel 2013 and I have a sheet that gets data from SQL Server 2012.
The query has 4 parameters and gets their values from cells. The box is checked to Refresh Automatically when cell value changes. I want to avoid using VBA.
Data is returned when correct values are in the cells referenced by the parameters.
The issue is with the cells that are dates. In another cell I create a formula that checks if the date is valid, if it is valid then format the entered value as YYYY-MM-DD else format today's date. On the first change the data is updated, but on subsequent changes the data doesn't update. The cell with the formula is used as the value for the parameter.
The issue seems to be that cells used for query parameters can only contains data or a simple function, no nested functions, for a change event to be recognized.
In my case: Cell I4 formats the user entered start date using =TEXT(F4,"yyyy-mm-dd"). If it is a date it is converted to text as SQL expects it else it is the same as the input. Cell J4 contains function for first day of current month =TEXT(TODAY()-DAY(TODAY())+1, "yyyy-mm-dd"). The cell used for the parameter is H4 and it contains =IF(F4=I4, J4, I4).
The next row (5) is similar testing the end date and J5 provides the month end date: =TEXT(EOMONTH(TODAY(),0), "yyyy-mm-dd") . Then the parameter cell for the end date contains =IF(F5=I5,J5, I5).
My next step is to take the query to a stored procedure for better input validation. Since excel seems to only allow 1 parameter for stored procedures (unless ODBC is used) I will have to concatenate the inputs is a cell like this: =TRIM(CONCATENATE(H2, "■",F3, "■", H4, "■", H5)) . Then split the criteria in the SP. Hope this helps someone.
I laid out the report, and I do a query that returns 30+ rows for a given period of time. One for each workflow. Now, I want to take that dataset (so the query only runs once) and define 6 datasets from it that filter it based on a single selected row. I will populate 8 boxes on the form for each of those datasets.
It appears that when you create a new dataset, it wants to go back to the datasource and ask you about all the data from that one again.
I was able to create a dataset that is a filtered view of the query and figured I could live with creating 6 datasets that ran the query each time filtering it differently each time. So, I need to do a 'copy' on the dataset and 'paste' it back in as a new dataset that is the same as the other one except with a new name.
I also need to set the default values for the Start/End date to be the 1st of last quarter, and the first day of this quarter. Is there a way to create calculated default values or do I need to do a query to return that?
if you are using table objects to create your report. you could use just 1 data set and add your filters to the table accordingly. just go to tablix properties>> filters tab.
for default values you can create expressions like for the first day of the current quarter:
=switch(DatePart(DateInterval.Quarter,today()) = 1, cstr(year(today))+"-01-01",
DatePart(DateInterval.Quarter,today()) = 2, cstr(year(today))+"-04-01",
DatePart(DateInterval.Quarter,today()) = 3, cstr(year(today))+"-07-01",
DatePart(DateInterval.Quarter,today()) = 4, cstr(year(today))+"-10-01")
I'm fairly new to SQL and I have been issued my first report to build. I have written an SQL query to give me a set of results that I would like to publish in a report.
I have unioned about 20 small queries all containing the correct amount of columns. One column is a misc column with about 15 different descriptions in (this is what I want to count).
I have uploaded my data set and now want to be able to choose a cell in my report to bring back a certain description.
At the minute I'm using
=count(fields!misc.values)
and it's giving me the whole count, about 200.
I would like to know if there is any kind of "where clause" (filter) which I can use to state which description results I want to bring back.
You can use am expression to count the misc.value you need. It will work like a count using a where clause:
=Sum(iif(Fields!misc.Value ="Some description",1,0))
Example:
For count the FSMethod with MethodOne as value I used this expression:
=Sum(iif(Fields!FSMethod.Value ="MethodOne",1,0))
Note the expression sums by 1 if the FSMethod.Value is MethodOne.
For count the rows with FSMethod column with MethodTwo value.
=Sum(iif(Fields!FSMethod.Value ="MethodTwo",1,0))
Let me know if this can help you.
I'm all about recycling-)
I have report that user want to run for selected number of month back (let say from 1 to 12).
If they selected 6 month back (Jul-13 thru Jan-2104, then I need to produce 6 pages with monthly report on each of them, and sp is the SAME for all reports just different time params.
How I can reuse my code??
For now I have 12 Tablix(s) with New Page=START, Hide condition set based on datediff(m,startDate,endDate) individually for each Tablix.
Then I need to run same sp with diff params, can I add some dynamics into it? or I better to have 12 sp(s)?
Thanks
Mario
You can achieve this with a single dataset and a List Report Item with an embedded Tablix:
Set the List Grouping to Group/Sort first by: =Year(Fields!YourDateField.Value) and then by =Month(Fields!YourDateField.Value).
Set the Page Breaks on the List Grouping to "Between each instance of a group".
Drag your Tablix inside the List Report Item.
Let me know if you need more detail.