SSRS cascading parameters for SSAS Tabular datasource with M2M relationship between dimensions in SQL Server 2014 BI - reporting-services

I'm trying to build a simple report using SSAS Tabular model as datasource. There are two different dimensions in the model - UserGroups that should be used as first parameter and Regions as second one. These dimensions are M2M-related in the model. Simple measure calculated with the usage of M2M tricks for tabular models works fine in Excel and PBID.
I need those parameters to be cascaded in SSRS report. I.e. Regions dropdown should be filtered after selecting one ore more (Allow multiple values parameter option is ON) values in UserGroups dropdown.
After I put both dimension onto Filter pane in Query Designer I receive two parameters with hidden datasets. Everything looks fine but first parameters (UserGroups) actually do not filter Regions dropdown.
I think I understand the nature of the issue. We see the same picture in other client tools like Excel when placing M2M-related dimensions on the same rows/columns pane - second dimension displays in the Pivot Table all its members until we check a measure in Pivot Table Fields. All the members for the second dimension (Regions in my case) are vanished as soon as a measure comes into play - Excel is smart enough to wipe out dimension members if the measure value is null. But this does not happen in SSRS.
All the "automatic" cascading parameters creation works well within hierarchies of a single dimension. I hope this works as well with one-to-many related dimensions. But how can I extend/modify automagically-created MDX query for the second parameter dataset to be filtered out? It looks like SELECT ( StrToSet ( #[UserGroupsUserGroups], CONSTRAINED ) ) ON COLUMNS is not enough in this case. I need also to check measure value to filter out Regions list. Unfortunately I'm not an MDX expert. Please help me to inject this checking into the query.

You're on the right track and gave a good explanation of the scenario. As you found out, there is no automatic way to make the parameters cascade. You do need to add an MDX filter to the second parameter to make this happen.
As far as the actual query is concerned, there's not quite enough information to give you an exact query. But you would use StrToSet to pass in the first parameter and use the FILTER function to limit the scope. As you stated, including a measure is one way to get only the "NonEmpty" combinations of the two parameters. If you run into a specific problem with a sample query, feel free to provide more details on that.

Related

Access - Modular reusable subreport

I would like to create a report which I can use as a sub-report multiple times on the same parent report. However, each occurrence of the subreport should have different values.
For instance, there is a table called DailyReport.
Records in this table contain:
Date, member, team, description
The sub reports should be for each team within a certain date range. However, the date range per subreport/team will not be the same.
So, if the date range for all teams was consistent, then I could create a single subreport, and do some Ordering on the resulting records to separate things out into teams.
However, with inconsistent date ranges, I can't utilize a single query, so the most straight forward solution I see is to create separate subreports and queries for each range of each team.
The problem with this solution is that if I decide to change the format of the subreports I must do so in each specific subreport--a lot of duplicate work.
I would like to create a generic query and subreport. The query and sub report would call VB functions which would return the relevant value.
This means my parent report has the same generic report on it multiple times. As each subreport is rendered, I would like to increment a value behind the scenes so that the functions which the generic query and subreport call know to return a different value.
However, it seems that's not how things work in Access. The subreports on a report are not rendered linearly. A subreport is created, and then "stamped" onto a report where ever required. This means that all of my generic subreports have the same data.
How can I define a generic report and query? Then plug in different values into the report and query while the report is being reused multiple times on the same parent report.
You need to look into the LinkMasterFields and LinkChildFields property of reports. They are designed for exactly this purpose -- to filter a subreport based on current data in the main report, without needing any code or even queries.
You are correct that LMF/LCF do not work on date ranges, only values. So use LMF/LCF for the team filter.
For the date range filtering, you can use an unbound form that launches the report as two parameters defined in the base query. Create frmLaunch, and add two text boxes minDate and maxDate. Set their Format property to Short Date so Access with interpret them correctly and provide the date pickers. Now modify the base query, adding two Date/Time parameters [Forms]![frmLaunch]![minDate] and [Forms]![frmLaunch]![maxDate]. Now, find your date field and set its criterion to Between [Forms]![frmLaunch]![minDate] and [Forms]![frmLaunch]![maxDate]. Add a button to frmLaunch that runs the code DoCmd.OpenReport "YourReportName", acViewPreview.
So, the goal was to make it possible to re-use the same sub-report multiple times on the same parent report, with full flexibility on how the subreport retrieves data.
I placed multiple instances of the same subreport on a parent report. On the subreports Open event I placed a line like
Me.Report.RecordSource = "SELECT * FROM someTable WHERE " & getCriteria()
nextCriteria()
Maybe its possible to pass a value that identifies which instance of the subreport is opening to the getCriteria function. Probably like a getCriteria(Me.Report.Name). But in this case I kept track of how many subreports had been produced in vb.
Unfortunately, if your subreport has controls which have a data source which is a vb function, all reports will show the same value for that control. To get around this I added something like getSomeValue() & "As [Some Value]" into the SELECT of the SQL statement above. Don't forget to add single quotes or hashes around getSomeValue() if you are passing a String or date.
That's basically it, it's a pain. But I couldn't find a more elegant way to do it.
Edit:
One major caveat I experience with doing this, is that although the print preview works correctly, when actually printing or exporting to PDF, some subreports would not be included. Maybe there is something else causing this...

SSRS ignore a field result

I guys
I'm having a slight problem with a report im currently writing.
So when i run this report it gives me a list of outcomes from a data source.
One of results is 'Closed' I want to exclude this outcome in my report. I cant exclude this in my SQL code as it doesn't bring back the null values. ( when no outcome has been given to a task yet i.e no one has had the time to do it yet i have set that in the expression to 'No Outcome'.)
So i want to know if anyone can edit my expression so it does not bring back the value of 'Closed'
=IIF(IsNothing(Fields!OutcomeDescription.Value),"No outcome",Fields!OutcomeDescription.Value)
Any Help on this would be great sorry if iv not explained this well.
Rusty
To do this, you'll want to add a filter to either your dataset or your table object - whichever is most appropriate for your needs.
For a dataset filter, merely open your dataset properties, and look for the filters tab. For a table, you'll need to go into the tablix properties. Setting up a filter from there is simple.
Filtering at the dataset level will drop all of the filtered records before any controls on the report could access them. Filtering at the object level would drop the filtered records from the control, but they would still be available to other controls. If your report only consists of a single table, and no additional objects, I'd recommend filtering on the dataset.

MS Access - using multiple queries in 1 report

I have about 35 queries in a large MS Access (2007) database that I would like to use in a report. However, I don't want to create reports for each query, but would rather include multiple queries in one report. The other questions relating to this on SO seem to be related to tables, but I am mainly concerned with just queries.
I have looked at several solutions so far, none of which seem to help:
1) DLookup - returns one value. I need to populate a report with many values from each query.
2) Subreports - I have tried to create text boxes to link my query data, but since they are unbound, it won't let me.
3) Yelling at it. I keep yelling at Access and it doesn't seem to help.
4) One giant query to get the values from all the smaller queries - it doesn't recognize the expressions I built in the smaller queries. Example: CustomerCount = DCount("[Customer_ID]","[Customers]"). Error: 'CustomerCount' is unrecognized.
Any ideas would be greatly appreciated.
Thanks,
If you are creating a report from one query that is made up of multiple subqueries, you can do this by populating textboxes. If looking at the properties on the report > Data tab > Control Source, you would place the name of the your subquery from your giant query and then the value you that you want.
For example:
Master query
SELECT
[Deb<30].CountOfACCT_ID, [Deb<30].SumOfB001,
[Deb<60].CountOfACCT_ID, [Deb<60].SumOfB001,
[Deb<90].CountOfACCT_ID, [Deb<90].SumOfB001,
[Deb>90].CountOfACCT_ID, [Deb>90].SumOfB001,
TodaysHD.CountOfACCT_ID, TodaysHD.SumOfB001,
TodaysLD.CountOfACCT_ID, TodaysLD.SumOfB001,
Part.CountOfACCT_ID, Part.SumOfB001,
FROM [Deb<30], [Deb<60], [Deb<90], [Deb>90], TodaysHD, TodaysLD, Part;
Each of the items in the FROM portion are subqueries being pulled into the master query. Then in your report you would populate the Control Source with [Deb<30].CountOfACCT_ID or whatever value you need from the master query. I have this setup in multiple reports in my application so it should work.
as for 2) you should be able to bind your controls, your subreport should have a record-source.
Else, try listboxes, their graphical apperance isn't exactly flexible, but they might get the job done.
regards,
//t

How to pass parameters to report model in Reporting Services

I'm developing report in RS that show top N customers based on some criteria. It also allows to select number of customers and period of time.
Is it possible to do it by using report model? Thing that it seems to be difficult is how to pass parameters determined by user.
Another thing that in my oppinion is very disappointing is that i cannot use SQL query as dataset query, because it uses odd and elaborate XML. Although report model items seem to map its fields to query or table fields.
I m concerning using report models because i need to provide uniform data model (the same tables and fields) for more or less different database schemas.
It would be very nice if somebody would explain what can be done with report models and what can not.
Maybe what you're looking for is to use the result of a Stored Procedure as the data source for your report. You would need to define parameters at a Dataset level to pass to the SP
You can create report model based paramaterized filters through the query designer by adding a filter, drag the field you want to filter on into the filter area, then right click on it and select "Prompt". This will automatically create a report parameter which you can then edit via the parameter properties dialog to set the data type, allow multiple values, etc.

Grouping by a report item in SSRS 2005 - textbox - any workarounds?

I want to group by a report item, but that's not allowed.
So I tried creating a parameter...not allowed as well.
Tried referencing from footer...failed again.
This is somewhat complicated.
Let me explain:
I have textbox22, it's value is:
=Code.Calc_Factor(Fields!xx.Value, fields!yy.Value...)
This is embedded VB code in the report that's called for each row to calculate a standard factor.
Now to calculate the deviation from the standard factor, I use textbox89, whose value is:
=(Fields!FACTOR.Value - ReportItems!textbox22.Value)/ReportItems!textbox22.Value
Don't get confused between Fields!FACTOR.Value and textbox22.Value, they are different.
Fields!FACTOR.Value is the factor used, textbox22.Value is what it should be (standard factor).
Now I want to create a group which splits deviations into 2 groups, > 1% or not.
So I tried creating a group:
=IIF(ReportItems!textbox89.Value > 1,0,1)
...But then SSRS complains about using report items.
I have run into a similar problem of using report items in the past, but this is a new case!
Any help greatly appreciated.
Have you tried adding a calculated field to your dataset?
Here is how it works:
While you are in the layout view of the report, open "datasets" tool window(in my environment it is on the left).
Right click on the DataSet you are working with and add a field, you can use a calculated field, and build your formula appropriately
Then you should be able to group on this field
-Dan
I'm not 100% that someone won't have some magic solution for this but I have run across similar problems myself in the past. I believe (but could be wrong) the problem Reporting Services is having is that it only renders once and what you're asking it to do is render the data before rendering the grouping which it doesn't do.
The only way I have ever been able to produce the exact results I need is to make the data rendering happen exclusively in the SQL (through the use of table variables usually) and then use Reporting Services merely as a display platform. This will require that your factoring algorithm gets expressed in the T-SQL within the stored procedure you will likely have to write to get the data in shape. This would appear to be the only way to achieve your end result.
This has the bonus feature of separating report design and presentation from data manipulation.
Sorry I couldn't provide a SSRS solution, maybe someone else will know more.