SSAS – Setting Attributes as Properties for Excel

When a user is browsing your cube with excel they may not understand how to slice the data and end up using things like “first name” as a hierarchy to slice the data. This does not make for good analysis, since grouping all of the people with the same name would not be useful (Unless your business is in analyzing names).

So a better practice is to set the “Attribute Hierarchy Enabled” property of the attributes to false, for attributes you don’t want the user slicing on, like First name, Last name, Email Address, and phone number. Then the user can see the properties in excel without having to do any slicing.

Below are examples using the employee dimension in Adventure Works. You can ignore the parent child relationship on the dimension.

Here is an example of what NOT to do:

In the below image you can see all of the attributes of the dimension are available and there are no hierarchies built. So if an end user wanted to slice by marital status and see the first and last names of the people in the different statuses, they would have to slice by all three of these attributes.

clip_image001

In Excel it would look like this:

clip_image002

clip_image003

This is confusing and is very bad for query performance.

To fix this you will need to build a hierarchy and let the user see the properties of the employee.

To do this:

1. Drag marital status into the hierarchies window in the center of the dimension editor

2. Drop the employee key under martial status

3. Rename the hierarchy to Marital Hierarchy

Now you can disable the attributes you don’t want the user slicing on like Phone, Login ID, Last name, First Name, and Email Address.

To do this:

1. Hold CTRL and click on each of the attributes listed above

2. In the properties window change the Attribute Hierarchy Enable Property to false

clip_image004

The Dimension Structure should look like the image below.

clip_image005

Click on the Attribute relationships tab and it should look like the below image.

clip_image006

Notice the Grey next to the disabled attributes in the bottom window. Now process and deploy the dimension and the cube.

The user will only need to slice by the Marital Hierarchy in Excel as seen in the image below.

clip_image007

The user can slice the information by marital status and then right click to see the properties of the employee as seen in the image below.

clip_image008

The employee Key is showing in this example because the login ID because the name property of the employee key was changed to the login Id.

The end user can now get the properties of each of the employees by right clicking on the employee and selecting “Show Properties in Report” and selecting the information they want to see.

clip_image009

Now selecting the first and last names do not slice the cube by the names and just show the names on the report as seen in the below image.

clip_image010

This should make your queries faster and allow your users to see the information they want without doing and lot of extra slicing.

To give you a deeper understanding of what is occurring here, imagine that you have millions of rows of data on your fact table and you drag out first name like in the example above of what NOT to do. This divides all of the data into groups by the first names. So anyone with the name Mike would be grouped together. Grouping the Mikes together is not useful. The only reason the user is doing this is because they want to see the name once they get down to the employee level.

By changing this behavior in your user and teaching them how to get the properties, your SSAS queries will run much smoother and give your users a better experience.

Posted in SSAS, Syndication | Tagged | 1 Comment

SSRS – Self Referencing Reports or Drill through to same report

When looking at a report and wanting to drill through to get more detail, we often create two reports for this. This can be accomplished by just one report by creating a self-referencing action that links to the same report. This can be done even if the report has parameters on it.

clip_image002

Above is a simplified example report. The list on the left contains the product ID’s. The table on the right shows the details for the product that the user clicks on. Also notice the different background color to show which item the user clicked. There is a parameter on the report for the product color. There is hidden parameter on the report for the product ID also.

There are two datasets on this report. The first contains the product ID’s. Here is that query.

SELECT ProductID

FROM Production.Product

Where Color = @Color

The second contains the Product details. Here is that query.

SELECT *

FROM Production.Product

Where Color = @Color and ProductId = @ProdId

Nothing special is done to the color parameter. The Product ID parameter needs a few adjustments. It needs to be set to allow blanks and nulls, and be hidden.

clip_image003

Add the two tables and use the details dataset on the details table and the product Id dataset on the product ID table.

Next you will create an action on the Product ID table. Right click on the data field and select textbox properties.

clip_image004

Click on the Action node. In here you will select “Go to Report” and select the report you are on as the drill down report. There are two parameters. The color parameter will map to itself. To do this click on the fx expression box next to the Color parameter and select the color parameter in the expression window. Select the product id from the drop down menu next to the product id parameter.

clip_image005

The last option is to highlight the background color of the product id that was clicked. The expression for that is below. You are comparing the selected product id with the product ID on the table and changing the background color if they match.

clip_image006

Now run the report and click on a product Id. Check the first image in the blog to see the results. Now you don’t have to leave the current report to see details.

Posted in SSRS, Syndication | Tagged | 4 Comments

Reverse or Mirrored Bar Chart in SSRS

There are some pretty charts out there and most of them can be done in Reporting Services. There is one type of chart I had someone ask for that is not natively built in to SSRS. But with a little manipulation you can get the look you want. Here is an example of the chart I am talking about.

clip_image002

This is a mirror chart showing the genders spread across age groups. The female chart is a basic chart with no extra work done to it.

Here is a sample of the data on the table I am querying. This is just a table I manually filled.

clip_image003

Here is the query and results I used for the Female dataset.

clip_image004

In the female dataset I am grouping by age range and getting a count of the gender column.

In the chart I set up the Gender as the value and the age range as the category.

clip_image005

The Male chart is does not turn out mirrored unless you do some trickery. Here are the steps you can take to get it mirrored.

First, add another column to the query, as you can see in the below image.

clip_image006

This “Diff” column gives you a number that is the difference between the gender count and the number 10. In your data you might need to use a bigger number.

Next you create a stacked bar chart.

clip_image007

In this chart you set the values to be diff and gender in that order. You set the category to age range.

clip_image008

Now for the trickery part, Right click on the Diff series and select series properties.

clip_image009

Click on the fill option on the left and set the color to no color.

clip_image010

The last step is to set the horizontal axis properties. Right click on the horizontal axis and select the properties.

clip_image011

Set the maximum to 10. In your data you might need a bigger number.

clip_image012

Then remove the vertical axis from the male chart if you desire. It should look like the image below.

clip_image013

You might need to manipulate your charts a little more to get them to look just right.

Posted in SSRS, Syndication | Tagged | Leave a comment

SSIS Execute SQL error – No disconnected record set is available

If you get the error in SSIS that says:

…failed with the following error: “No disconnected record set is available for the specified SQL statement.”. Possible failure reasons: Problems with the query, “ResultSet” property not set correctly, parameters not set correctly, or connection not established correctly.

This is can be due to the record set in an Execute SQL task being set to the wrong result set and the task not returning a dataset. For example, if the Execute SQL task is executing an insert statement, there is no returned dataset. But keep in mind that the insert statement does run and will write the data to the table. In this case the record set should be none.

clip_image002

Posted in SSIS, Syndication | Tagged | Leave a comment

SSRS Map Layers Parameter

With the new Map control in SSRS 2008 R2 there are three different map types, Road, Aerial, and Hybrid. If you want to allow your users to change the map type you would think you could map a parameter to the property on the tile layer with these three types. If you map a parameter to the map type and try to change the type the report stays on the original map setting. But there is a trick to get this to work.

First create a parameter with the three map types in the available values.

clip_image002

Then create three tile layers on the map, one of each type, Road, Aerial, and Hybrid.

clip_image004

Then set the visibility property of these layers to a parameter with the values to compare them to.

clip_image006

The function in the map tile visibility property for hybrid will be.

=iif(Parameters!MapType.Value = “Hybrid”,”Visible”,”Hidden”)

Set the visibility for the other layer based on their names. This will cause your report to run slower due to the report pulling down three layers of maps.

Posted in SSRS, Syndication | Tagged | 1 Comment

SSAS – Process everything

This is just  short blog with a quick tip for those that don’t know.

When working with SSAS it is sometimes necessary to process every dimension before continuing with development. This can be accomplished with a couple of clicks on the menu bar in BIDS. Click on Database and then process.

clip_image001

Then you will see each dimension processing and the cube.

clip_image002

Posted in SSAS | Tagged | Leave a comment

SSIS Pivot on bad data

The pivot transform in SSIS is already a pain to use. When you have bad data it makes it even worse. In this blog I am going to show how to handle bad data when using the pivot transform. You should understand how to use the pivot transform already and Devin Knight has a great blog on how to do that here.

Here is the input table:

image

The output table should look like so:

image

This is a situation where the users have entered data and they have left off the types on the input table and therefore we do not know where the value should go. These values will be dropped in this example. When loading the output table we need to pivot the data. Another issue is the IDs of the incoming data are sequential and not matching. So IDs 1-5 are the first row, 6-10 are the second row and so on.

Here is the data flow used to perform all of this work.

image

All of these issues can be handled in SSIS with native task. We will use an aggregate transform in this example. Remember an aggregate transform is an Asynchronous transform and does not perform well if you have a lot of rows. This aggregation could be done with a staging table if that is the case.

Here is the query used to pull the information from the input table:

SELECT ID, isnull(Type,’X’) as Type, [Value]

FROM dbo.PivotInput

This will give us the following table:

image

In the pivot transform you can create a column to catch all of the X columns. These are the rows missing the type.

image

After the pivot transform the data will look like the below image in a data viewer:

image

Here you can see that the data has been pivoted but the ID issue still needs to be resolved. You need to place ID 1-5 on the same row and 6-10 on the same row and make this work for all numbers. You will do this with a derived column and the aggregate transform.

The next transform is the derived column. Here you will create a new ID column with the following expression:

image

Now after the derived column the data will look like the below image:

image

Notice now you have a New ID that can be grouped together. The aggregate transform will do this.

Here is how the aggregate transform is set up:

image

Notice you are dropping the X column. You could do a multi cast before this to map those bad rows to another output like a flat file for someone to examine manually.

After all of this we map it to the output and the table looks like so:

Let me know if you have any weird situations like this. I always love a good challenge.

Posted in SSIS, Syndication | Tagged | Leave a comment

SSRS Nulls in a matrix

In a recent SSIS class one my students ask me, if you are reporting off a table and using it in a matrix, does the matrix show null rows. The answer is yes. Here is an example table and the resulting report.

clip_image002

Notice the row with all Nulls does not show, but as long as the grouping field has a value it will show a row.

clip_image004

Posted in SSRS | Tagged | Leave a comment

Missing Foreign Keys in SSAS DSV

When creating report models you might run into bad database designs where the tables have no foreign keys and/or no primary keys. This can be resolved in the report model DSV. I have created two tables, one with first names, the second with last names. Each has an ID column which is the row that matches the row on the opposite table. There are no primary keys and no foreign keys on either table.

clip_image002

In visual studio I created a report model project and selected the database with these two tables. Then I created a DSV with these two tables.

clip_image004

After you create the DSV (Data Source View), right click on the DSV and select open.You will see the two tables in the DSV view.

clip_image006

Then I right clicked on the row to set a primary key. Remember this row must be unique.

clip_image008

Then I dragged the first ID to the second ID to create the foreign key. Remember, these must be matching data types.

clip_image010

Then I create the model and it has the relationships needed to create reports.

clip_image012

I created a report in report builder 2.0. Here you can see how the names match up correctly.

clip_image014

Posted in SSAS | Tagged | Leave a comment

SSIS Records on the Same Row – kind of like pivot

If you have two or more records on the same row, and need to write each record on its own row in a destination, you have two choices. You can do this in series or parallel in a single data flow in SSIS. Here is the input table I am using for my example.

clip_image002

Notice I have three names on one row. I need these to be inserted into a table with a first name and last name column only. So all three first name fields need to be mapped to the only first name columns on the destination and the same is true for the last name column.

The first method I will show is using a multicast and a union all as seen below.

clip_image004

The multicast clones the data into three data flow line. In the union all we will now select the first name and last name columns to union together. We are going to stack them as shown and delete the unused columns. This gives us only two columns out of the union all.

clip_image006

This makes the mapping in the destination easy. It is simply two columns to two columns.

clip_image008

The second method is to spilt the data up and write it to the database in parallel. Here is that data flow.

clip_image010

This will write the data to the data base for each customer in a separate destination.

Name 1 Destination mapping.

clip_image012

Name 2 Destination mapping

clip_image014

Name 3 Destination mapping

clip_image016

Here is the data on the destination table after the load. Notice the names are all on individual rows.

clip_image018

In terms of performance, the parallel load works about twice as fast. This is in part due to the union all being a partially blocking transform and the parallel is writing three fields at once. This is a huge performance hit. If the parallel load time is 5 minutes, then the series load time would be about 10 minutes. This may seem small, but scalability should always be considered.

Posted in SSIS, Syndication | Tagged | 1 Comment