MDX Functions: BottomCount

The MultiDimensional eXpressions, or MDX, language is used to query the data in a multidimensional in an OLAP database.  In the case of examples here, SQL Server Analysis Services. This example uses the Contoso demo cube available for download here: http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=18279
Function Name: BottomCount
Use Case: Brings back the lowest X number of values from a set
MSDN Link: http://msdn.microsoft.com/en-us/library/ms144864.aspx
Notes: Always breaks a hierarchy
Syntax: BOTTOMCOUNT(<<MDX Set>>, Number of Tuples to return, <<Measure>>)
Sample Query:
SELECT
[Measures].[Online Sales Amount]
ON COLUMNS,
BOTTOMCOUNT(
[Product].[Product Category].CHILDREN,
2,
[Measures].[Online Sales Amount]
)
ON ROWS
FROM [Contoso]

Sample Results:

About the author

Bradley Schacht

Bradley Schacht is a Principal Program Manager on the Microsoft Fabric product team based in Jacksonville, FL. Bradley is a former consultant, trainer, and has authored 5 SQL Server and Power BI books, most recently the Microsoft Power BI Quick Start Guide. As a member of the Microsoft Fabric product team, Bradley works directly with customers to solve some of their most complex data problems and helps shape the future of Microsoft Fabric. He frequently presents at community events around the country, is a contributor to sites such as SQLServerCentral.com, and is a member of the Jacksonville SQL Server User Group (JSSUG).

Add comment

Bradley Schacht

Bradley Schacht is a Principal Program Manager on the Microsoft Fabric product team based in Jacksonville, FL. Bradley is a former consultant, trainer, and has authored 5 SQL Server and Power BI books, most recently the Microsoft Power BI Quick Start Guide. As a member of the Microsoft Fabric product team, Bradley works directly with customers to solve some of their most complex data problems and helps shape the future of Microsoft Fabric. He frequently presents at community events around the country, is a contributor to sites such as SQLServerCentral.com, and is a member of the Jacksonville SQL Server User Group (JSSUG).

Follow Me