Monday, July 25, 2011

MDX: Replacing Null / Empty Values

In the result of an MDX query, you may get some empty or null values which you'd want to treat differently, such as considering them as 0s. For instance in Reporting Services, you might want to filter out any rows with 0 or empty values.

In such cases, you can use the MDX function CoalesceEmpty, which replaces an empty cell value with a given value. For instance:

WITH MEMBER [Measures].[NonEmpty Discount] AS
     COALESCEEMPTY( [Measures].[Discount Amount], 0 )

will replace any empty values of discount amount with zero.

Very useful in certain scenarious.

MSDN Documentation: http://msdn.microsoft.com/en-us/library/ms146080.aspx
Tags: mdx replace replacing get getting null empty values measure zeros

Friday, July 22, 2011

SSRS: Hierarchies issue in report parameters with Analysis Services

Reporting Services offers great support for Analysis Services (getting data from cubes). Admittedly however, you will sooner or later meet with several little annoyances that hinder report development, especially if you are not confident or have no knowledge in MDX.

One common issue occurs when setting a dimension hierarchy as a parameter, as in screenshot 1 (for this example, I will be using Customer Geography hierarchy in the AdventureWorks Cube).
Screenshot 1 - Parameter
Reporting Services automatically creates a new hidden dataset, that retrieves the dimension members and all the members of its levels to use as available values for the report parameter. For instance, if you want the countries as parameter, you also get cities and names along with it, which could make the dropdown list parameter huge and messy, as in screenshot 2. While sometimes this is desired, other times it is not.

Screenshot 2 - Large dropdown list
So what can you do if you want only the countries? One option, of course, is to have each level as a separate hierarchy defined in the cube, as seen in the AdventureWorksDW. This is not always possible however. The steps below show you how to do this in the report, and can be applied for any case.

Solution 1 (if you only need the top level in the hierarchy):
  • In the Report Data, right click the Datasets folder and select "Show Hidden Datasets".
Screenshot 3 - Show Hidden Datasets
  • Right click the new dataset that appeared, and select "Query...". You'll be shown some scary, unformatted code (called MDX). Don't fret!
Screenshot 4 - MDX with ALLMEMBERS
  • In the code, there is one and only one place with the text "ALLMEMBERS", as seen in screenshot 4. This can be safely replaced with "CHILDREN" as in screenshot 5. If you execute the query, you will see that you only get the members without all the lower levels.
Screenshot 5 - MDX with CHILDREN
  • Click OK to save the query and preview the report. The dropdown list only shows the countries now, and is much cleaner than before.
Screenshot 6 - Clean dropdown list
Solution 2 (to get a specific level in the hierarchy):
  • The first solution works only if you require the members at the highest level (in the example, countries). But what if we want cities only for example? The first thing is to repeat the steps as above until screenshot 4.
  • This time, we will leave ALLMEMBERS as it is, and instead replace the statement preceding it. In this case, it is [Customer].[Customer Geography]. In the left column under the Metadata tab, find the level that you require and hover the mouse over it to get the statement you need, as in screenshot 7.
Screenshot 7 - Getting level MDX statement
  • We replace the statement in the MDX code as shown in the screenshot above. Finally we get the desired level members.
Screenshot 8 - Dropdown list with cities
Tags: reporting services analysis services mdx report parameters hierarchies level issue problem messy large dropdown list

Thursday, June 23, 2011

Microsoft SQL Server Reporting Services vs PerformancePoint Services

These 2 products aren't often compared with each other, and they are in fact different. However there are times where their capabilities overlap and reasons for using one instead of the other may be unclear, especially when using these tools together with Analysis Services.

Since not much information on such aspects seem to be available on the internet, below is a basic list displaying some comparisons.


Product
Standardized reports
Dynamic dashboards
Audience
Few to many users
Power users
Usage
Operational and Management
Strategy and Management
Measures
Fixed
Changeable
Dimensions
Fixed
Changeable
Drilldown
Fixed drilldown or drill through path as defined in report
Flexible drilldown for any report
Styling
Customizable to the lowest detail
Fixed appearance
Distribution
Online, Email, File Share or Printed
Online
Export
CSV, Excel, Image, PDF, Word or XML
Excel, PowerPoint (Individual Dashboard Elements)
Security
At report level. Users see what the report displays
At data warehouse level. Users see all data they have access to

It is certainly possible to implement some tricks or workarounds in order to achieve some capabilities such as styling in PerformancePoint using CSS, but those were the general aspects of the two tools. It should give a good idea of the differences.

Saturday, May 7, 2011

Hello World!

Welcome to yet another tech blog. Since every IT geek has an IT blog, then why not have one too? Though part of the reason comes from motivation from a colleague.

Topics I’ll be posting about can vary depending on what I’m currently working on. For instance, as I’m currently working on reports and analytics, you can expect a few posts regarding Reporting Services coming up, including some tips and workarounds of common issues, especially concerning Analysis Services.

Otherwise I’m a fan of C# and game development, so things may be headed that way too.