Monday, November 23, 2009

SSAS and percentage measures

Scenario

Let's say you have the following base measures that are the raw data held in the source system:

  • ListPriceDollars
  • StandardDiscountPercentage

The cube users require these two measures and an additional StandardDiscountPriceDollars measure to be available for use.

In this situation, it's easy to get stuck at the point of ensuring StandardDiscountPercentage displays sensible numbers at all aggregation levels. There are plenty of options to play with - aggregation functions, measure expressions, calculated members, etc. For people with more of a SQL than MDX background there's a lot to understand here. Throw in some null values and a parent-child relationship and you'll be torturing yourself trying to find the best way to represent this in SSAS.

Solution Option

One possibility is to completely avoid trying to aggregate percentages.

  1. Change your source view or named query to calculate StandardDiscountPriceDollars (=Product.ListPriceDollars / (1 - (Product.StandardDiscountPercentage/100))
  2. Don't use the raw StandardDiscountPercentage value in the cube - instead, create a simple replacement calculated member (= 1 - ([Measures].[Standard Discount Price Dollars] / [Measures].[List Price Dollars])

With a little bit of zero and null handling the job will be done.

Thursday, November 12, 2009

Getting MDX from Excel pivot tables

  1. Data: Connections
  2. Properties
  3. Select Definition Tab
  4. Add Log File=c:\temp\pivotlog.txt;
  5. OK
  6. Close
  7. Refresh Pivot

Note: the definition text provided above is case sensitive! Particularly Log File

Tuesday, November 10, 2009

Displaying data source information in Reporting Services reports using expressions

The following expression is about the best I have come up with:

=DataSources("myDataSource").DataSourceReference & " " & DataSources("myDataSource").Type

This will display:


  • Data source name - probably also "myDataSource" in this example. The full path is provided when the report is run in Report Manager
  • Data source type e.g. "OLEDB-MD" is an Analysis Services data source

Limitations:

  • You can't use expressions referring to data sources in the header or footer. But who wants the data source details displayed in the report body??
  • The data source reference has to be hard coded in every report. I'm not aware of any way to enumerate this to just fetch the first datasource. It would be fantastic if the following worked, but it doesn't:
=DataSources[0].DataSourceReference & " " & DataSources[0].Type

Monday, November 2, 2009

Pausing SQL Server transactional replication without losing queue contents

To Pause:
  1. Open SSMS and connect to the distributor
  2. Disable and Stop the "Distribution clean up: distribution" job
  3. Expand SQL Server Agent, right-click on Jobs, select View Job Categories and choose REPL-Distribution
  4. Disable and Stop all listed jobs
To Continue:
  • Enable and Start all the jobs that were stopped
I have seen countless forum discussions for this topic but no succinct list of steps.