Need an account? Click to Register
MDX Challenge

Can MDX do what nextanalytics does? One of our blogs explored this point. A well known blogger and industry veteran Mosha Pasumansky, accepted the comment as a challenge to demonstrate that MDX could indeed easily produce the sample analytic posed in the blog. Please note, it wasn't actually a very tough analytic, as compared to the other examples we've been walking you through.  In any case, the ensuing interaction was enjoyable for everyone who checked in. Mosha wrote a great post in his own blog and was successful in proving that MDX was easily capable of delivering on the sample query.  His response can be found verbatim here.  

Our own opinion on what he wrote was that it must be understood that when Mosha wrote the code, (1) he assumed the cube already existed, and (2) it took someone (very?) skilled in MDX to produce it.  Mosha is one of the inventors of MDX and an architect on Microsoft Analysis Services engine, and an author of a book on MDX, by the way.

Can you write the kinds of MDX that Mosha can?  If you can't, or you don't have a cube, then we now present nextanalytics as an alternative. In that sense, we compete with MDX. Even if you do have a cube, you can have a combined solution by using a simple MDX query, augmented by the capabilities of nextanalytics.  In this sense, we complement MDX. 

The point is, less experienced MDX and SQL and CSV programmers working with a wide variety of data sources can now perform extremely powerful analytics either using nextanalytics by itself or with it running complementary to the query language and server capability.  All in all, this means that pretty well no matter what data source you use and platform you run on, with only a modest level of business intelligence experience, you can now obtain advanced analytics.

Overview

The blog has the example embedded in it. Here's the solution in nextanalytics.

The full nextanalytics script is shown in the Detail section, following this overview.

Overview

part 1  
rolling six month avg RollingPeriods,Column,0,-1,6,Average
period over period growth RepeatingCalculation,Growth
PageCaption,p1
count each time "growth" less than row average  AutoPopulateBaselines
Test,Average from p1,LessThan,0,GreaterThan,6,0  ,False,False,False,True,not,True,Above,True,Keep,False
keep only rows above average 6 or more times FilterByValue,KeepByVal,GreaterThanOrEqualTo,Row,-1,Above,False, 0,6,True,Actual
PageCaption,Results of Part 1
part 2  
keep only first & last columns Select,Page,Product Sales By Month
Select,Column,First
Select,Column,Last
KeepSelected

calculate growth from first to last RepeatingCalculation,Growth
remove rows below 25 % growth FilterByValue,RemoveByVal,LessThan,Row,-1,Last,False,0,25,True,Actual
PageCaption,Results of Part 2
part 3  
intersect part 1 and part 2 SetMath,Results of Part 1,Results of Part 2,both

Detail

The following is the entire script. It was recorded using an Open Source "Author Mode" which is provided with every download as well as at CodePlex.com. The entire thing can done with clicking, no typing was needed (except for the page titles).  It's the kind of thing a business user could do, without needing a DBA or BI analyst looking over their shoulder.

Notice that this example doesn't need a cube. It runs perfectly fine off a CSV file (from Excel) or SQL query.  It could also run off an MDX server, even if it didn't support the advanced functionality that Microsoft OLAP has such as SAP BW or Essbase.   If you are using an IBM Cognos product, or an SAP Business Objects Crystal product, you could also take advantage of nextanalytics by using nextanalytics to write its processed data into a table or importable file. nextanalytics also has an Open Source module which creates a DataGrid and DataTable on the fly, which means that many popular charting components such as Dundas Visualization can render the results.

By examining the following code, we think you'll agree that it is readable, could be thrown away without a significant loss, or it could be enhanced by a stranger (to the code) when the analytic requirement evolved.

Complete script listing
  1. prompt,add,[ConnectionString],"Server=db01;UID=user;PWD=pass;Database=AdventureWorksDW;"
  2. query,command,ProductRegionMonthSales.sql
  3. query,runsave,SQL,[ConnectionString],QueryResults.nod
  4. SwapTextColumnWithColumn,month
  5. PageCaption,Product Sales By Month
  6. RollingPeriods,Column,0,-1,6,Average
  7. RepeatingCalculation,Growth
  8. PageCaption,p1
  9. AutoPopulateBaselines
  10. Test,Average from p1,LessThan,0,GreaterThan,6,0, False,False,False,True,not,True,Above,True,Keep,False
  11. FilterByValue,KeepByVal,GreaterThanOrEqualTo,Row,-1,Above,False,0,6,True,Actual
  12. PageCaption,Results of Part 1
  13. Select,Page,Product Sales By Month
  14. Select,Column,First
  15. Select,Column,Last
  16. KeepSelected
  17. RepeatingCalculation,Growth
  18. FilterByValue,RemoveByVal,LessThan,Row,-1,Last,False,0,25,True,Actual
  19. PageCaption,Results of Part 2
  20. SetMath,Results of Part 1,Results of Part 2,both

As a convention, we like to keep the SQL in a different file (as follows). This makes it easier to modify it externally, or programmatically as the case may be...

ProductRegionMonthSales.sql
  1. SELECT d.EnglishProductName AS rowlabel_product,
  2.   b.SalesTerritoryRegion AS text_region,
  3.   Convert(varchar(7),c.FullDateAlternateKey,120) AS text_month,
  4.   a.SalesAmount AS numeric_sales
  5. FROM dbo.FactInternetSales a, dbo.DimSalesTerritory b,dbo.DimTime c,
  6.   dbo.DimProduct d
  7. WHERE a.SalesTerritoryKey = b.SalesTerritoryKey
  8.   AND a.ShipDateKey = c.TimeKey AND a.ProductKey = d.ProductKey
  9.   AND c.CalendarYear = 2003
  10. ORDER BY c.FullDateAlternateKey

 

 
< Prev   Next >