One of my customers wanted to count their top selling products. Since sharing is caring I will show you how this can be achived in this post 🙂
I want to list all products that sold for at least 5000 dollars in the year 2005.
DEFINE MEASURE 'Internet Sales'[Sales] = SUM ( 'Internet Sales'[Sales Amount] ) EVALUATE ADDCOLUMNS ( FILTER ( SUMMARIZE ( CROSSJOIN ( VALUES ( 'Date'[Calendar Year] ), VALUES ( 'Product'[Product Id] ) ), 'Date'[Calendar Year], 'Product'[Product Id] ), 'Internet Sales'[Sales] >= 5000 && 'Date'[Calendar Year] = 2005 ), "Sum of Sales", 'Internet Sales'[Sales] ) ORDER BY 'Internet Sales'[Sales] DESC
And the result will look like this
If you want to only display the number of products you can add “row” and “countrows” like this
DEFINE MEASURE 'Internet Sales'[Sales] = SUM ( 'Internet Sales'[Sales Amount] ) EVALUATE ROW ( "Count", COUNTROWS ( ADDCOLUMNS ( FILTER ( SUMMARIZE ( CROSSJOIN ( VALUES ( 'Date'[Calendar Year] ), VALUES ( 'Product'[Product Id] ) ), 'Date'[Calendar Year], 'Product'[Product Id] ), 'Internet Sales'[Sales] >= 5000 && 'Date'[Calendar Year] = 2005 ), "Sum of Sales", 'Internet Sales'[Sales] ) ) )
And the result will look like this