SSRS: adding a Matrix based on 2 DataSets - sql-server

I just started working with SSRS, and figured out how to connect my MDX Query to a Cube and plug that into a Matrix
However, i need to have a matrix, and in each section, i need to call a different DataSet.
For example:
Matrix1 would have a repeating section based off DataSetA (let's say its customer centers).
in each section (customer center) of Matrix1 i would have a Expression, which calls DatasetB, using a value from DataSetA as parameter (let's say it would be a separate MDX query getting some other information based on customer center ID).
so my expression from within a tablix cell is something like this:
=First(Fields!MTD_Trades.Value, "DatasetB")
is it possible to pass a MDX query filter (or where clause) using a parameter from this point?
ideally it would be something like this (pseudo code):
=First(Fields!MTD_Trades.Value, "DatasetB") WHERE Fields!Where_Filter.Value
something along these lines.. where the MDX WHERE section is dynamic based off another query
UPDATE - solution explanation
here is an example of what i am doing: Let's say the application is based on air traffic and the business user here is some aviation authority person. I will give that person a UI that will let them define the slices they want to see. For example they can come in, and create n slices (i.e. International Flights, Flights leaving US, Flights Arriving After Midnight, Flights with 50+ passengers... n). As you can see, they will have the freedom of adding any filters they wish to each slice.
Then based on their actions (using GUI), i will generate the necessary MDX queries (one for each slice).
My challenge here is to create a SSRS report that will show a separate line for each one of those slices (1-n). Hope that helps in understanding my conundrum. The first part of the query will be the same for each slice (# of flights), but the WHERE section will be different and dynamic for the report.

You can use the lookup() function to access data in another dataset from within a reportitem but you cannot run multiple sub-queries within the report. You can only do this within the parameters where one parameter can be an input for another query driven parameter.
The best course of action is to modify your original query to contain all the data you need for the Matrix.
EDIT: It sounds like you need to use a multivalue parameter.
In the "Slices" parameter set it to allow multiple values
In the dataset which accept this parameter, goto the parameters form and set the value to an expression which is =Join(Parameters!Slices.Value,",").
Pull apart the string in you query and run each subquery then return as a set.

Related

Can I Fix the a lookup field in Access database based upon a calculation or another field?

I am trying to create a database with field descriptions for a very large excel file that I have at work. I have created 3 tables- List of sheets, list of variables(including a lookup field pointing at the List of sheets table, so that I can select the sheet to which the variable belongs), and a third table which specify some validation rule.
In this third table, I want to see two lookup fields, one specifying the sheet in which the rule applies(say, 'Select Sheet'), and another specifying the variable(say, 'Select Variable'). I can point to the two different tables, but I want to do something a bit more nuanced than that. When I give a particular sheet name to 'Select Sheet', I want the lookup field for the variable('Select Variable') to show me only those variables which exists in that sheet.
I know that there probably will be solutions using forms, but this database is going to be very detailed and there are things to do afterwards, so I do not want to get into queries and forms before all data has been recorded in tables in a neat manner.
I have a good grasp of VBA in the context of excel and I am given to understand that I can extend the applications of Access using VBA. I am ready to do that, but I want to see before that whether this is some functionality of access that I am missing. Had anyone done anything similar before, and if so, did it take VBA to do it?

SSRS Error - "Report item expressions can only refer to fields within the current dataset scope or, if inside an aggregate

I'm new to SSRS and I'm not sure if it will do what I would like to do.
I'm getting the following error in SSRS:
"The Value expression for the text box 'Textbox17' refers to the field 'DayCnt'. Report item expressions can only refer to fields withing the current dataset scope or, if inside an aggregate, the specified dataset scope. Letters in the names of fields must use the correct case."
I have a list that's 3 rows and 3 columns. I need to use multiple data sets across the rows and columns. I would like everything on the report to be grouped on the school ID, which each dataset does have.
I will be using multiple datasets per cell in some cases and I'm using a textbox and then dragging the dataset field into it. I'm not sure if grouping is the problem. I'm not sure how to group the entire list at once, or if it is row based, or how the grouping works with a list with multiple columns.
How can I get everything in the list to be based off of the school ID?
You can reference more than one dataset in the same data region (table, etc.) but only if it makes sense to use aggregate functions on all the datasets except the primary one that your grouping is based on. I'm not sure if this makes sense for your use case or not.
An aggregate function is something like First. If you don't specify the dataset, it defaults to the "current dataset." The current dataset is an invisible default that you can't see or set anywhere in the UI, as far as I can tell.
=First(Fields!MyField.Value)
vs.
=First(Fields!MyField.Value, "MyDataset")
Now, there are a couple of tricky things to know about the Report Builder UI.
When you drag a field into your report, the expression it creates does not specify the dataset.
When you drag a field into your report, it changes the current dataset!
This leads to exasperating behavior such as the following:
Create a data region.
Set its grouping to a field from Dataset1.
Drag in a field from Dataset1.
Run the report. It works!
Drag in a field from Dataset2. RB will automatically use an aggregate function, as you would expect.
Run the report again. Now you get an error, not on either of your fields, but on the grouping of your data region.
The problem is that dragging in the field from Dataset2 changed the current dataset to Dataset2 and broke everything that uses Dataset1 without explicitly specifying it. The solution is hacky:
Manually change the expressions of all your fields from Dataset2 so they explicitly reference the dataset, or
Reset the current dataset by dragging in a field from Dataset1 and deleting it.
You cannot use different datasets on only one SSRS table. One table should only refer to one dataset.
And the solution to your question is: recreate your dataset (query), try to get one dataset by using distributed query if they are on different server instance, or specify database name when they are on the same server.
You might have done some modification on the Dataset and you did not refreshed the fields.

Tableau - 2 Custom SQL Queries - One Parameter updates two sheets

I have two different data sets using two different SQL queries. Essentially one data set is day/caller stats rolled up the other set is call data. So each call data set rolls up to get their day/caller data.
I needed to separate these two queries for performance because I needed one extract and one parameterized custom query for the call data. So essentially I will always bring in this month of data and last month for the day/caller data.
What I need to do is create one dashboard, that has the caller and all of their stats aggregated for the time period. Then I need to be able to click a row to prompt all the call data in a different sheet on the same dashboard
I am at the home stretch and need a way to connect these two sheets and update the call data. Right now I only have a parameter for the Unique ID of the callers not time, I bring in all the same days of calls even though it is really not needed. In a perfect world I will click the report caller and my second query will update to the appropriate day range and Unique ID and produce only that callers calls. My problem right now is no matter what I do I cannot create the one sheet to update the second call sheet. I have successfully created a manually functioning report but I need the action to filter to a timer period and the specific caller.
Let me know if you have any feedback. My two issues are creating two separate queries caller data (225k rows help in export) call data (7 million rows if unfiltered) which needs to be a live connection so when sheet is clicked the parameters will update and those calls will populate. Anything would help!
The solution i can think of is to use an action filter and there is an option below to select the fields to map between the sheets.Choose selected fields instead of all fields and map the id and time between the two data sources.
Apart from this i dont really get what the issue is.If you need further clarifications please rephrase your questions and provide examples and your data structure.

SSRS: Partial re-use of a MDX query? OR MDX as Parameter?

in Sql Server Reporting Services Report
is it possible to define a MDX query within a report, and then re-use it a bunch of times, but each time with different WHERE section.
i.e. the Members and SELECT section would be the same for each row (MTD.Count YTD.Count)
but, i'd want to filter it 10 different ways..
The only way i can think of doing this right now, is adding 10 datasets, each with a different WHERE section, but i'd like to re-use just one DS
ALTERNATIVELY
Another totally acceptable option would be to supply whole MDX queries to the report as parameters of some sort. My challenge is that my MDX queries are generated dynamically (including the # of actual queries), all of that is user driven. So is there a way i could supply n MDX queries to a report, and have it plug that into a matrix? One way i thought of doing this today, is to emit the whole RDL XML dynamically..
You can have the dataset using a few parameters like this:
SELECT
{
StrToSet(#rowAxisMdx)
} ON 0,
{
StrToSet(#columnAxisMdx)
} ON 1
FROM [Cube]
WHERE {
#StrToSet(#slicerAxisMdx)
}
It will be slow since you are using a lot of StrToSet functions, but it should work.
This is most likely my solution:
Subreports
Yep, subreports saved me here.. My actual goal was to repeat the same MDX query with a different WHERE section for each row. Sub reports are design for just that. You can define a matrix and bind it to a dataset. That dataset will determine how many rows of data your matrix will be populated it.
You can embed a subreport in a cell of your matrix, and pass it a parameter (in my case i am passing the whole WHERE filter, but you could make it more granular and only pass a field.
Then in your subreport you can display just one set of information based on a parameter which is passed in from parent report.
here are some more links
SubReports
Designing Reports with Custom MDX Queries

Dynamic selection of dataset in SSRS

I am going to design a report using SSRS 2005. Is it possible to have the selection of dataset done dynamically?
Let's say I am going to have two tables, where the first one is the summary and the second is the detail data. One of my parameters (with values Summary and Detail) will determine which version of the report is to be displayed. Can I have two different datasets, and while clicking the view report button in parameter view dialog (or before) set which dataset which will be used?
You can use the single data set by using switch statement some thing like this:
You can type this in data tab but the results can be seen only in preview tab, but not the data tab like regular queries.
=Switch(Parameters!ToDecide.Value = "Summary",
"Your query for Summary",
Parameters!ToDecide.Value = "Detail",
"Your query for Detail")
Make sure you don't have any excess spaces with in the query(not more than one space where needed)
Both the queries should return the values required by the Table in Layout.
You'll probably have to have 2 pairs of table contained in, say, a rectangle, and hide the unused one (at the container level). Or use subreports.
If you find a way to switch datasets, then you'll have to make sure that all columns are the same as well as making sure that any functions using the DataSet as a scope parameter are changed too... which makes me think it just isn't supported.
You might want to try using a single dataset and having a summary and detail data region (table, list, etc.) in the report, one of which is visible and one of which is not. In this scenario, the dataset is only evaluated once and you are still meet your requirement.
Hope this helps,
Bill
It would be easier to create and maintain if you have two separate tables and hide one or the other depending on the choice made.
I haven't tried this, but I think another possibility would be to use three reports: a container, a summary subreport, and a detail subreport. Switch between the subreports according to the choice.
There is a performance gotcha to the first implementation though. SSRS will try to fill every DataSet in the report when it loads, even ones that are not used in the report's output or by other DataSets or expressions. In other words, just because you're displaying the summary report, doesn't mean that you're not asking the database to fill out your detail data as well.
There is a workaround that can improve the performance a bit, but will still end up with a trip to the server. The hack is to set a flag parameter to determine whether or not the query should actually return any real results or if it should just return the columns you want.
You may try adding condition that depends on a cetain parameter to execute. Then from there, You may use different data set. Assuming that you'll use it on separate hidden tablix.

Resources