Basket Analysis with #dax in #powerpivot and #ssas #tabular

Posted by Marco Russo (SQLBI) on SQL Blog See other posts from SQL Blog or by Marco Russo (SQLBI)
Published on Thu, 12 Jun 2014 07:25:00 GMT Indexed on 2014/06/12 9:35 UTC
Read the original article Hit count: 350

A few days ago I published a new article on DAX Patterns web site describing how to implement Basket Analysis in DAX. This topic is a very classical one and is also covered in the many-to-many revolution white paper. It has been also discussed in several blog posts, listed here in historical order:

As usual, in DAX Patterns we try to present the required DAX formulas in a way that is easy to adapt to specific models. We also try to show a good implementation from a performance point of view. Further optimizations are always possible in DAX. However, in order to keep the model simple to adapt in different scenarios, we avoid presenting optimizations that would require particular assumptions or restrictions on the data model.

I hope you will find the Basket Analysis pattern useful. Even if you do not need it today, reading the DAX formula is a good exercise to check your knowledge of evaluation contexts in DAX. For example, describing how does it work the following expression is not a trivial task!

[Orders with Both Products] :=
CALCULATE (
    DISTINCTCOUNT ( Sales[SalesOrderNumber] ),
    CALCULATETABLE (
        SUMMARIZE ( Sales, Sales[SalesOrderNumber] ),
        ALL ( Product ),
        USERELATIONSHIP ( Sales[ProductCode], 'Filter Product'[Filter ProductCode] )
    )
)

The good news is that you can use the patterns even if you do not really understand all the details of the DAX formulas you are using!
Any feedback on this new pattern is very welcome.

© SQL Blog or respective owner

Related posts about Analysis Services

Related posts about BISM