The “CrossJoin” function returns the Cartesian product of all rows from all tables in the arguments. In my sample below I want to have sales per year per city.
EVALUATE ADDCOLUMNS ( SUMMARIZE ( CROSSJOIN ( VALUES ( 'Date'[Calendar Year] ), VALUES ( Geography[City] ) ), 'Date'[Calendar Year], Geography[City] ), "Sum of Sales", CALCULATE ( SUM ( 'Internet Sales'[Sales Amount] ) ) )
And the result looks like this
But as you can see I get a lot of empty rows. To remove these empty rows I add a filter to my query. I also moved my calculation outside the main query to make it more readable.
DEFINE MEASURE 'Internet Sales'[Sales] = SUM ( 'Internet Sales'[Sales Amount] ) EVALUATE ADDCOLUMNS ( FILTER ( SUMMARIZE ( CROSSJOIN ( VALUES ( 'Date'[Calendar Year] ), VALUES ( Geography[City] ) ), 'Date'[Calendar Year], Geography[City] ), 'Internet Sales'[Sales] <> 0 ), "Sum of Sales", 'Internet Sales'[Sales] )