414 Practical PowerPivot & DAX Formulas for Excel 2010
Y
ou may have SSAS data mining structures and data mining models. You
normally query these objects using Data Mining eXtensions (DMX), perhaps
from SQL Server Management Studio (SSMS) or from SQL Server Reporting
Services (SSRS). Although this release of PowerPivot supports the graphical design of
SQL and MDX queries, it does not support the graphical design of DMX queries. You
can, however, write your own DMX. You do so by connecting to an SSAS source and
entering the DMX into the MDX Statement area of the Specify a MDX Query dialog,
in the Table Import Wizard. Another way is to embed your DMX query within a SQL
query and import the data returned from the outer SQL query. To do that, you connect
to a SQL Server source and enter the SQL/DMX into the SQL Statement area of
the Specify a SQL Query dialog of the Table Import Wizard. Alternatively, you can
query some data mining data from Excel itself—for this you will need to download the
data mining add-in for Excel (the data mining results are shown in an Excel worksheet
when you use the Table Tools/Analyze ribbon, rather than the Data Mining ribbon),
you can then import or link into the PowerPivot window from the Excel worksheet).
Stand-alone DMX, or DMX embedded in SQL, works for DMX Cases, Content,
Prediction, and other queries. This chapter includes sample code for a few Cases, Content,
and Prediction queries.
C
Key concepts DMX, linked servers, Cases queries, Content queries, Prediction
queries
Why Write DMX Queries?
DMX, or Data Mining eXtensions, is a standard language for extracting data from data
mining models. Specifically, it is the language used to query data mining structures and
data mining models in an SSAS database. By using DMX, you are no longer confined
to SSAS imports from cubes only—you can also import data from mining models. You
can write your own stand-alone DMX queries during data import. One other way to
get DMX imports working is to set up a SQL Server linked server to SSAS, and embed
the DMX within a SQL query. This appendix shows both approaches.
If you are interested in learning a bit more about DMX (in particular, DMX for
SQL Server Analysis Services), refer to my book, Practical DMX Queries for Microsoft
SQL Server Analysis Services 2008 (McGraw-Hill /Professional, 2010). Most of the
examples here are taken from that book.
Where to Create and Test DMX Queries
DMX is a standard language for querying data mining models. The DMX discussed
here is for SSAS. The DMX used by other vendors of data mining software may differ
in minor ways.