• Post Categories

  • Browse Blogs

  • Blog Stats

    • 486,068 hits
  • Syndications

    SQLServerPedia Contributor

SSAS errors: DefaultMember(Measures,Measures) (1, 1) The ‘[xxx]’ member was not found in the cube when the string, [Measures].[xxx], was parsed.

When attempting to browse an Analysis Services cube you may be presented with the following error message:

DefaultMember(Measures,Measures) (1, 1) The ‘[xxx]’ member was not found in the cube when the string, [Measures].[xxx], was parsed.

The error message is self-explanatory. There is a Default Member being referenced and was not found. But, pinpointing where this “DefaultMember” is being referenced may me a bit challenging.

The Root Cause

The root cause of this issue is quite simple: a deleted or renamed measure is still being referenced by its original name. Some of the areas where this deleted or renamed default measure could still be referenced by its original name include:

  1. Cube DefaultMeasure property
  2. Perspective DefaultMeasure property
  3. Calculations

The fix

The fix may involve adding the measure back or renaming the measure to its original name or digging through several areas of the cube where the deleted or renamed measure is still being referenced by its original name. Here are your options:

1. Add or rename the measure back to its original name.
This may not be the desired option, but it could be the easiest and quickest way to fix the issue.

2. Modify each Perspective’s DefaultMeausure property
Unfortunately, deleting or renaming a measure does not “trickle-down” where it is being referenced in a perspective. The original measure’s name will remain.

3. Change the cube DefaulMeasure property to the new measure name.
Similar to Perspectives, deleting or renaming a measure does not “trickle-down” its new name to the cube’s DefaultMeasure property. You will need to select a new measure in the DefaultMeasure property.

4. Modify the cube XML code
This option may be a little daunting to some, but in the end it is the quickest way to make sure the original measure’s name is replaced by the new measure’s name. To do this, in Solution Explorer right click on the Cube’s name and select View Code. The XMLA definition will open. At this point, press CTRL+H or click on Edit->Find and Replace->Quick Replace.The Quick Replace window will open. Type the original measure’s name in the “Find what” textbox and type the new measure’s name in the “Replace with:” textbox.

Dynamically generate current Year, Month or Date member with MDX

MDX can be extended with Visual Basic functions like the FORMAT() and NOW() functions to dynamically generate the current year, month or date member. For example, it can be used as part of a named set to generate current year budget and actuals. It can also be used as part of a filter in a Performance Point dashboard.

First, a little review of VB NOW() and FORMAT() function:

NOW()

The NOW() VB function returns the current system date and time. It is similar to the T-SQL GETDATE() function.

FORMAT()

The FORMAT() VB function returns a string formatted according to instructions contained in a format String expression.
Source: http://msdn.microsoft.com/en-us/library/59bz1f0h(v=vs.90).aspx

There is an extensive list of characters you can use to create your own date and time formats. You can see the complete list here: http://msdn.microsoft.com/en-us/library/73ctwf33(v=vs.90).aspx

For example, you can extract the year portion of your date in the following formats:

y: Displays the year number (0-9) without leading zeros. Use %y if this is the only character in your user-defined numeric format.
Example: FORMAT(NOW(), “y”)
Result: 1 (for any date in 2011)

yy: Displays the year in two-digit numeric format with a leading zero, if applicable.
Example: FORMAT(NOW(), “yy”)
Result: 11 (for any date in 2011)

yyy or yyyy: Displays the year in four-digit numeric format.
Example: FORMAT(NOW(), “yyy”) or FORMAT(NOW(),”yyyy”)
Result: 2011 (for any date in 2011)

FORMAT() and NOW() with MDX

The following MDX example uses the Adventure Works 2008R2 Analysis Services OLAP cube. Suppose we need to return all Internet Sales for the year 2011. The MDX script would look something like this:

SELECT [Measures].[Internet Sales Amount] ON COLUMNS
FROM [Adventure Works]
WHERE [Date].[Calendar Year].&[2011]

This works just fine and will return the aggregated sales of 2011. (Note: the Adventure Works 2008R2 does not contain sample sales data for 2011, result will be an Empty dataset).

But what if instead of a specific year, you are asked to return the Internet Sales amount for the current year? You have 3 options:

  1. On January 1st at 12:01 AM every year you need to change your MDX script to the new current year.
    CONS: You might be passed out from celebrating New Year’s Eve and most probably you will not get to it until a few days out into the new current year.
  2. You could use some MDX functions like LasNonEmpty and LastChild to figure out the last amounts recorded by the most recent date.
    CONS: You may have forecast data or simply bad data with transactions occurring on dates out into the future. (Trust me, I’ve seen it)
  3. You can build a dynamic MDX script that will return the current year based on the system datetime.
    CONS: It may be too sexy for your cube.

The trick is to construct the Date dimension member using the STRTOMEMBER MDX function. The STRTOMEMBER MDX function stands for “String to Member” and as the name implies, it will convert a string to a dimension member. In this case, we want to generate the [Date].[Calendar Year].&[2011] dimension member from a string using the Year portion of the system datetime.

The dynamic string will look like this:

StrToMember(“[Date].[Calendar Year].&[“+FORMAT(NOW(), “yyyy”)+”]”)

Now we can use it in our MDX script:

SELECT [Measures].[Internet Sales Amount] ON COLUMNS
FROM [Adventure Works]
WHERE StrToMember(“[Date].[Calendar Year].&[“+Format(now(), “yyyy”)+”]”)

The same applies if you want to select or filter data for the current month. In the following example I’m be using the Month level from the Calendar Hierarchy and specifying the month of July (7) for the year 2011:

SELECT [Measures].[Internet Sales Amount] ON COLUMNS
FROM [Adventure Works]
WHERE [Date].[Calendar].[Month].&[2011]&[7]

We can generate the current month member as follows:

SELECT [Measures].[Internet Sales Amount] ON COLUMNS FROM [Adventure Works] WHERE StrToMember(“[Date].[Calendar].[Month].&[“+Format(now(), “yyyy”)+”]&[“+Format(now(), “M”)+”]”)

Note that to specify the Month portion we use CAPITAL letter M because it is case-sensitive. Smallcase letter m stands for minute. The complete list of characters can be viewed here: http://msdn.microsoft.com/en-us/library/73ctwf33(v=vs.90).aspx

Top 10 reasons to attend SQL Saturday #62 Tampa

We will jumpstart 2011 with the first SQL Saturday event of the year in Tampa, FL on January 15th, 2011. SQLSaturday #62 is a joint effort between the Tampa Bay SQL Server User Group along with the  Tampa Bay Business Intelligence User Group, its volunteers, members, speakers and sponsors.

I’m fortunate of co-organizing the event with one of the most experienced User Group leaders and SQL Saturday organizers, Pam Shaw (Twitter | Blog). It is great to have a mentor such as Pam and learn from her past experience organizing this type of events.

This will be the 4th SQL Saturday organized in Tampa. It will be held in an area of Tampa known as Ybor City (wiki) with a lot of Spanish, Cuban and Italian influence. As with previous years, we will be providing awesome Spanish food for lunch. This year we will also have two paid pre-conferences for the SQL Server/DBA track and Business Intelligence track the day before SQL Saturday on Friday, Jan 14th.

So why not come down to Tampa? SQL Saturday #62 has so many great speakers and sessions. We had over 45 different speakers who submitted more than 75 different sessions. The list was narrowed down to fit the number of rooms and time slots available, giving opportunity to new speakers as well as seasoned speakers and MVPs.

These among many other reasons make up the Top 10 reasons why you should attend SQL Saturday #62 Tampa, FL:

1) Preconferences

SQL Saturday #62 Tampa, FL will have its free sessions on Saturday Jan 15th as well as two paid pre-conferences on Friday Jan 14th. Yes, you read correctly, two all-day pre-conferences the day before SQL Saturday. The pre-conferences have a registration cost of $99. Price includes course materials, coffee, donuts, lunch, water and sodas. You can register for the paid all-day training events at:  http://sqlsaturday62.eventbrite.com/

The two pre-conferences scheduled are:

Pre-con A: Storage and Virtualization for the DBA
Presenter: Denny Cherry
Abstract: This session will be a two part session in which we will be focusing on two of the biggest topics in the DBA field, how to properly design your storage and virtualization solutions.

 Pre-con B: End-to-End Business Intelligence
Presenter: Stacia Misner
Abstract: This session will cover the basics of ETL using SSIS, a deeper focus on mutl-dimensional cube design using SSAS, effective report design using SSRS and an introduction to PowerPivot ad-hoc analysis.

If the pre-conferences (Reason #1) are not reason enough to come to SQL Saturday #62, these are additional reasons to attend;

2) Learn for free : 

Yes, free! No strings attached. All expenses for Saturday sessions are covered by event sponsors and volunteer time and effort by speakers, organizers and user group members.

3) Quality sessions by world class speakers:

And did I mention free sessions on Saturday? Learn from the best in the industry, SQL Server Most Valued Professonals (MVPs), book authors, bloggers, and certified professionals. Take a look at the MVP speaker line-up for SQL Saturday in Tampa, FL: 

MVPs                            

Adam Jorgensen
David Dye
Denny Cherry
Geoff Hiten
John Welch  
Jonathan Kehayias
Kevin Boles
Plamen Ratchev
Rodney Landrum

4) Networking opportunities

At SQL Saturday you have the opportunity to create new friendships, establish professional relationships with other professionals, meet your rockstars and if you are on Twitter, get to meet the source of some of those odd and funny tweets! You have a full day to hunt down and stalk your rockstars, enjoy a casual over lunch conversation or have more deep conversations over a drink at the after party!

5)  Talk to industry leader vendors and explore their products and services

Advaiya
Confio
CozyRoc
Enterprise Software Solutions
Enterprise Software Solutions
Fusion-IO
Gerasus Software
KForce
Melissa Data
Microsoft
Pragmatic Works
Professional Assosciation of SQL Server (PASS)
Redgate
SQL Server Magazine
Tavolacci & Associates / YouCanLearn
Confio
Fusion-IO
Enterprise Software Solutions
Pragmatic Works
Tavolacci & Associates / YouCanLearn

6) SQL Karaoke – SQL Saturday Edition
Show off your talent at the SQLSaturday after party. SQL Karaoke is a must-do event for everyone. Sing along with some of the SQL Server professionals for good’ol fun. We will have our after party at Rock-N-Sports Bar & Bistro at Centro Ybor.

7) Great food
We will be providing free lunch and back by popular demand we will be delighting you with Spanish/Cuban cuisine!

8 ) Enjoy warm and sunny weather
Escape from the cold weather and come down to Tampa. Enjoy a weekend in Ybor City, visit Busch Gardens, or take a trip to the beach.

9) Job opportunities
Looking for a job or planning a career move? Kforce representatives will be on site to talk about several job openings in the area and nationwide. Make sure to visit their booth.

10) Get your Swag on!
As an attendee you will receive a bag full of free swag from our sponsors and raffle tickets for a chance to win netbooks & other electronics, software licenses, training vouchers, books, etc.

Creating a Top 1, Top 10, Top n Customer or Product List using Named Sets in SSAS Part 1 of 3

Just like stored procedures in SQL Server, Analysis Services provide  a similar functionality through stored MDX expressions called named sets.  SQL server stored procedures allow you to:
– Return a set of data from your database
– Can be reutilized by being called in scripts
– Are named descriptive of the data they return (ideally)

Similarly, SSAS allows you to create reusable pieces of MDX code that can be called in other MDX scripts by its name or alias and have the same characteristics as described above. Additionally, these reusable pieces of MDX code may or may not use parameters just like parameter-less stored procedures.  In essence a Named Set is a predefined subset of your cube or a sub-cube. For purpose of simplicity I will go over named sets that do not use parameters.

One of the most common queries requested by Sales and Marketing Managers is a list of Top 10 Customers.

This list of customers may be required in ad-hoc queries as well as weekly, monthly, quarterly or yearly sales reports. This is where Named Sets in SSAS are most beneficial. Instead of rewriting the same MDX query over and over and having to change it everywhere you use it each time the criteria for Top 10 customers changes (believe me it will), you simply call this named set and whatever changes you make to the named set trickles down to wherever you call it.

The general MDX syntax to define this Named Set is:

CREATE SET CURRENTCUBE.[Top 10 Customers]
AS
TopCount
(
  (Existing [Customer]. [Customer].[Customer].Members]),
  10,
  [Measures].[Sales Amount]
);

As you can see the MDX function that helps us easily create this list is TopCount(). The keyword *Existing* forces the data set to be reevaluated each time dimension criteria changes, for example if different time period such as Year,  Quarter or Month is selected or if the cube is sliced by a particular product. In this case, the Top 10 Customers list will be generated based on the criteria applied.

Conversely if you need to create a list of the 10 least profitable customers or least profitable products for example, you can use the BottomCount() MDX function in a similar fashion.

Special attention needs to be taken when using BottomCount() MDX function for customers or products that had no correponding sales amount for the given criteria. For example if during last month 15 customers have no sales [Sales Amount]=0 or [Sales Amount] is NULL, then BottomCount() customers list will be made up of customers with $0 or NULL  sales amounts. These $0 and NULL sales amount records can be filtered out using the Filter() MDX function for $0 values and with the NONEMPTY() MDX function.

In Part 2 of this post I will be providing some examples of Named
Sets using the Filter(),  NonEmpty() and another useful function called Item() which allows you to select a particular tuple from a set.

In Part 3, I will be explaining the difference between TopCount() vs. Head() and BottomCount() vs Tail() MDX functions. In some instances a particular function might be simpler and more efficient.

Variance calculation using MDX calculated measure in SSAS

Actual vs. Expected Variance Analysis focuses on the difference between the projected or expected amounts and the actual amounts. These type of analysis are part of an important set of metrics for decision makers in all type of organizations and can be applied to Budgets, Production, Revenues, Profits, Efficiency and many other areas.

In SSAS OLAP cubes, these variances could be calculated through several ways. An easy and simple way to accomplish this is through calculated members using MDX in SSAS. There are several other ways to accomplish this calculation but for the scope of this post I chose a simple and quick way for beginner MDX’ers.

The Math
The basic formula for variance is:

Variance = Expected – Actual

The Requirements

You have been tasked to create an Actual Budget Variance cube in Analysis Services for the CEO of your company. In this cube the CEO is interested in viewing the Budget, Actual Budget, Expected Budget and Actual Budget Variance by Department and by Quarter.

Let’s assume we already have the Actual Budget Variance SSAS cube solution already created with a Department and a Quarter dimension as well as with the three Measures already loaded in our OLTP Data Warehouse (Budget, Budget Expected, Budget Actual):
(Click on image to expand)

We need to dynamically calculate the Actual Budget Variance as follows:

Actual Budget Variance = Budget Expected – Budget Actual

To create this calculation in SSAS follow these steps:

1) Open the Analysis Services Project Solution in Business Intelligence Development Studio (BIDS) and click on Calculations Tab and create a new calculated Member as follows:
(Click on image to expand)

2) Save the Solution and Process the cube.

3) Once processed, click on Browser Tab to browse  the cube. Expand the Measures group and you should see the new calculated member. Drag all measures and both dimensions into the browsing area. Group the Department Dimensions under the Quarter Dimension by moving Department column to the right. You can expand and collapse the Quarter Dimension to show/hide the details. It should look something like this:
(Click on image to expand)

From this example you can understand the basics of creating a calculated member using MDX. You can see the full script of the MDX calculated member by clicking on the Script View icon in toolbar under Calculation.
(Click on image to expand)

%d bloggers like this: