| DAX Queries, Part 4 |
| Written by Chris Webb | |||
| Thursday, 28 July 2011 01:10 | |||
|
Reposted from Chris Webb's blog with the author's permission. I was extremely pleased to see that there was a Crossjoin() function in DAX, if only because it meant that I wouldn’t have to rename my company. Let’s see how to use it… The Crossjoin() function returns a table that returns the cross join of two table expressions. Here’s a very simple example: evaluate( In this case the two parameters for Crossjoin() return a table of distinct values from DimDate[CalendarYear] and DimDate[FiscalYear], and the table returned gives every combination of values from those two tables. From an MDX point of view, it’s interesting to note that we really do get every single combination: there’s no auto-exists being applied, and we get combinations like CalendarYear 2001 and FiscalYear 2004 that do not exist in the DimDate table (I have no problem with this – it’s what I’d expect to happen in DAX). I can imagine using Crossjoin() in a number of different ways, although the most obvious scenario is in a query along with the Summarize() function, for example: evaluate( It’s worth comparing the query above with the output of the following query: evaluate( Notice how, in the first query, you get one row for every distinct combination of Year and Category whether there are any sales or not, whereas in the second query you only see the combinations where sales exist.
|
Author articles
- Controlling the Position of Subtotals in DAX with GenerateAll()
- Self-Service BI Mapping with Microsoft Research’s Layerscape–Part 2
- Self-Service BI Mapping with Microsoft Research’s Layerscape–Part 1
- Aliasing Columns in DAX
- Using Google Docs, Data Explorer and PowerPivot for Questionnaires
Most Popular
- Step by step guide on installing PowerPivot for SharePoint on a single machine
- List of suggested datasets to test PowerPivot
- List of PowerPivot DAX functions with description
- How to install PowerPivot for Excel and list of know issues
- Microsoft Virtual Lab: PowerPivot for Excel 2010 Introduction
- List of PowerPivot DAX functions (short)
- Learning PowerPivot and DAX
- PowerPivot's impact on BI pros?



