Using SSRS Reports with SSAS Cubes


Published on

Take your reports to the next dimension! In this session we will discuss how to combine the power of SSRS and SSAS to create cube driven reports. We will talk about using SSAS as a data source, writing MDX queries, using report parameters, passing parameters for drill down reports, performance tuning, and the pro’s and con’s of using a cube as your data source.

Jeff Prom is a Senior Consultant with Magenic Technologies. He holds a bachelor’s degree, three SQL Server certifications, and is an active PASS member. Jeff has been working in the IT industry for over 14 years and currently specializes in data and business intelligence.

Published in: Technology
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • A dimension is the descriptive attribute of a measure.
  • Quadruple, quintuple
  • Calculated members = With member… x + y
  • If you do just ‘where condition1, condition1’ it will give an error on the comma
  • Empty - only the rows having NULL for all the members of the set defined in the column axis is filtered out.NonEmpty - returns the set of tuples that are not empty from a specified set. Basically what’s in the () part is what get’s evaluated. It will then only show records that have a value.Non Empty – If the whole fact table doesn’t have a value, it is truly NULL. Then it get’s filtered out.NonEmpty – On the query result set, if there are no results, then it should get removed.
  • @ReservationNumber is not using the MDXString, just the value.
  • @ParkName is actually using the MDXString value.
  • When the CONSTRAINED flag is used, the member name must be directly resolvable to a qualified or unqualified member name. This flag is used to reduce the risk of injection attacks via the specified string. If a string is provided that is not directly resolvable to a qualified or unqualified member name, the following error appears: "The restrictions imposed by the CONSTRAINED flag in the STRTOMEMBER function were violated." When the CONSTRAINED flag is not used, the specified member can resolve either directly to a member name or can resolve to an MDX expression that resolves to a name.
  • Using SSRS Reports with SSAS Cubes

    1. 1. Using SSRS Reports with SSAS CubesPresented By:Jeff PromSenior ConsultantMCTS - Business Intelligence (2008), Admin (2008), Developer (2008)Magenic Technologies
    2. 2. Agenda1. The How & Why of using SSRS with Cubes2. Using SSAS as a Data Source3. Writing MDX queries4. Refactoring SSRS to use SSAS5. Demo6. Performance Tuning7. Questions / Wrap up
    3. 3. Why run reports from a cube?• Cubes may be readily available• Cubes may be your company’s primary data source• Cubes may be your only resource• ‘Canned’ reports can be created/scheduled/Emailed• May want to use SSRS instead of Excel
    4. 4. Primary Differences• Connect to a cube rather than a relational database• Report queries will use MDX instead of T-SQL• Report Parameters will use MDX• Report Field Sources will use XML• More difficult / time consuming
    5. 5. SSAS• Online Analytical Processing (OLAP) Cube data structures• Great for numeric analysis• Pre-calculated aggregations• Dimensional Model / Star Schema• Facts (Measures) & Dimensions
    6. 6. SSAS• Member – An item in a dimension representing one or more occurrences of data. – The lowest level of reference when describing cell data in a cube.• Tuple – Used to define a slice of data from a cube. – Composed of one or more members.• Set – An ordered collection of zero, one, or more tuples.
    7. 7. MDX Basics• MultiDimensional Expressions (MDX)• MDX lets you query multidimensional objects, such as cubes, and return multidimensional cellsets.• Parent/Child hierarchical structure• Comment your code with: – -- – // – /* Code Block */• Terminate queries with a semicolon ;• Write/test your MDX queries in Management Studio first!
    8. 8. T-SQL vs MDX StructureT-SQLSELECT DISTINCT DATEPART(year, ReservationDate) FROM FactReservationDates;MDXSELECT { } ON COLUMNS,{ NONEMPTY([Reservation Dates].[Calendar Year].Children) } ON ROWSFROM [HT Cube];
    9. 9. Using MDX in Report Queries• STRTOSET – Converts a string to a set• STRTOMEMBER – Converts a string to a member• Cross Join – Combines tuples of one set with the tuples of another – Use * to combine multiple dimensions• Can’t execute more than one MDX query at a time in SSMS in the same query window.• Beware of the ‘All’ and ‘Unknown’ members.• If you have multiple conditions in your WHERE clause, you need to enclose them in ( ) – e.g. WHERE (condition1, condition2, condition3);
    10. 10. Double Empty?• Non Empty vs NonEmpty() – Non Empty is a prefix and is used to remove empty record sets – NonEmpty() returns the set of tuples that are not empty from a specified set
    11. 11. MDX Filtering• Filtering in the WHERE clause• Inline filtering – [Customers].[CustomerID].&[123] – Use with ON ROWS• Using ‘Filter’ – Checks tuples to see if it exists within the filter condition – Use with ON ROWS
    12. 12. SSRS• Data Source: Use Microsoft SQL Server Analysis Services• Queries need to use MDX instead of T-SQL• Parameter Values need to use MDX data sources – May also need to convert string values into MDX.• Field sources will be in XML
    13. 13. Report Fields: T-SQL vs MDX (XML)
    14. 14. XML Field Source Values• Numeric Values – <?xml version="1.0" encoding="utf-8"?><Field xmlns:xsi=" instance" xmlns:xsd="" xsi:type="Measure" UniqueName="[Measures].[Total Amount]" />• Dimension Values – <?xml version="1.0" encoding="utf-8"?><Field xmlns:xsi=" instance" xmlns:xsd="" xsi:type="Level" UniqueName="[Customers].[Customer Name].[Customer Name]" />
    15. 15. Calculated Fields• Use Calculated Fields to pass MDX parameter strings – ="[Reservation Dates].[Calendar Year].&["+Fields!CalendarYear.Value+"]"
    16. 16. Passing Parameters Between Reports• Passing Single Values – Easier – Two options when passing parameter values: 1. Pass the parameter name (e.g. @Parameter) and then convert it back into an MDX string in the subsequent queries and use a StrToMember function.
    17. 17. Passing Parameters Between Reports• Passing Single Values – Two options when passing parameter values: 2. Or, create and pass a Calculated Field as an MDX string and then use the StrToMember function.
    18. 18. Passing Parameters Between Reports• > 1 Value – Typically More difficult – Have to convert to MDX string values – In MDX use StrToSet
    19. 19. Demo
    20. 20. Performance Tuning - SSAS• Ensure the SSAS server has sufficient hardware• Tune aggregations on your cubes• Use Partitions – By Time – By Geography• Add a Constrained flag to StrToSet and StrToMember functions – More secure and improves performance – StrToMember([Geography].[Geography].[Country].[Germany].FirstChild, CONSTRAINED)
    21. 21. Performance Tuning - MDX• Performance tune MDX queries• Use Named Sets to avoid recalculating set expressions• Use Calculated Members to cache numeric values• Apply filters to limit the result sets• Only use StrToSet and StrToMember when using SSRS parameters• Use the NonEmpty function wherever possible
    22. 22. Performance Tuning - SSRS• Avoid returning too many records (~ 2,000+)• Use parameters and filtering to limit records returned• Try to avoid resource intensive reporting features – Fixed Data (Advanced Mode) – Repeat on New Page (Advanced Mode) – Matrix reports with column groupings
    23. 23. Gotchas• Constant balancing act between using parameter strings, MDX Values, and data set values.• BIDS2010 – If you put the wrong XML field name values, you will get warnings even AFTER you fix it. Need to close BIDS and restart.• BIDS2008 – Avoid using the query wizard! – Can change your queries back to the original – The MDX wizard likes to ‘Hide’ your datasets
    24. 24. Pro’s & Con’s• Pro’s – Ability to report off of existing cubes – Take advantage of SSAS aggregations• Con’s – Writing queries can be more difficult / time consuming – Using parameters can be more complex – Not the most efficient for large, detailed reports
    25. 25. Links• Analysis Services Connection Type for MDX (SSRS) –• Microsoft SSAS Overview –• Microsoft MDX Overview –• Microsoft SSRS Overview –
    26. 26. Questions?Jeff Prom• Contact Info – Blog: – Email:
    27. 27. Thank You!Jeff Prom