Using SSRS Reports with SSAS Cubes

27
Using SSRS Reports with SSAS Cubes Presented By: Jeff Prom Senior Consultant MCTS - Business Intelligence (2008), Admin (2008), Developer (2008) Magenic Technologies

description

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.

Transcript of Using SSRS Reports with SSAS Cubes

Page 1: Using SSRS Reports with SSAS Cubes

Using SSRS Reports with SSAS CubesPresented By:

Jeff PromSenior ConsultantMCTS - Business Intelligence (2008), Admin (2008), Developer (2008)

Magenic Technologies

Page 2: Using SSRS Reports with SSAS Cubes

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

Page 3: Using SSRS Reports with SSAS Cubes

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

Page 4: Using SSRS Reports with SSAS Cubes

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

Page 5: Using SSRS Reports with SSAS Cubes

SSAS• Online Analytical Processing (OLAP) Cube data structures• Great for numeric analysis• Pre-calculated aggregations• Dimensional Model / Star Schema• Facts (Measures) & Dimensions

Page 6: Using SSRS Reports with SSAS Cubes

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.

Page 7: Using SSRS Reports with SSAS Cubes

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!

Page 8: Using SSRS Reports with SSAS Cubes

www.microsoft.com/webcasts

T-SQL vs MDX StructureT-SQLSELECT DISTINCT DATEPART(year, ReservationDate) FROM FactReservationDates;

MDXSELECT { } ON COLUMNS, { NONEMPTY([Reservation Dates].[Calendar Year].Children) } ON ROWS FROM [HT Cube];

Page 9: Using SSRS Reports with SSAS Cubes

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);

Page 10: Using SSRS Reports with SSAS Cubes

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

Page 11: Using SSRS Reports with SSAS Cubes

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

Page 12: Using SSRS Reports with SSAS Cubes

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

Page 13: Using SSRS Reports with SSAS Cubes

Report Fields: T-SQL vs MDX (XML)

Page 14: Using SSRS Reports with SSAS Cubes

XML Field Source Values• Numeric Values

– <?xml version="1.0" encoding="utf-8"?><Field xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="Measure" UniqueName="[Measures].[Total Amount]" />

• Dimension Values– <?xml version="1.0" encoding="utf-8"?><Field xmlns:xsi="http://www.w3.org/2001/XMLSchema-

instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="Level" UniqueName="[Customers].[Customer Name].[Customer Name]" />

Page 15: Using SSRS Reports with SSAS Cubes

Calculated Fields• Use Calculated Fields to pass MDX parameter strings

– ="[Reservation Dates].[Calendar Year].&["+Fields!CalendarYear.Value+"]"

Page 16: Using SSRS Reports with SSAS Cubes

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.

Page 17: Using SSRS Reports with SSAS Cubes

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.

Page 18: Using SSRS Reports with SSAS Cubes

Passing Parameters Between Reports• > 1 Value

– Typically More difficult– Have to convert to MDX string values– In MDX use StrToSet

Page 19: Using SSRS Reports with SSAS Cubes

Demo

Page 20: Using SSRS Reports with SSAS Cubes

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)

Page 21: Using SSRS Reports with SSAS Cubes

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

Page 22: Using SSRS Reports with SSAS Cubes

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

Page 23: Using SSRS Reports with SSAS Cubes

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

Page 24: Using SSRS Reports with SSAS Cubes

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

Page 25: Using SSRS Reports with SSAS Cubes

Links• Analysis Services Connection Type for MDX (SSRS)

– http://msdn.microsoft.com/en-us/library/dd239327.aspx

• Microsoft SSAS Overview– http://msdn.microsoft.com/en-us/library/bb522607.aspx

• Microsoft MDX Overview– http://msdn.microsoft.com/en-us/library/ms145514.aspx

• Microsoft SSRS Overview– http://msdn.microsoft.com/en-us/library/ms159106.aspx

Page 26: Using SSRS Reports with SSAS Cubes

Jeff Prom• Contact Info

– Blog: http://jeffprom.wordpress.com– Email: [email protected]

Questions?

Page 27: Using SSRS Reports with SSAS Cubes

Thank You!

Jeff Prom