Azure Analysis Services

Query Data in Azure Analysis Services

This document provides an overview of how to query data in Azure Analysis Services. Azure Analysis Services supports standard query languages like DAX (Data Analysis Expressions) and MDX (Multidimensional Expressions), as well as REST APIs for programmatic access.

Using DAX

DAX is a formula expression language used in Power BI, Analysis Services, and Power Pivot in Excel. It's designed for querying tabular data models. You can execute DAX queries against Azure Analysis Services models.

Example DAX Query

EVALUATE
SUMMARIZECOLUMNS (
    'Product'[Category],
    'Date'[CalendarYear],
    "Total Sales", SUM ( 'Sales'[Quantity] * 'Sales'[Net Price] )
)
ORDER BY 'Product'[Category], 'Date'[CalendarYear]

Using MDX

MDX is a query language for multidimensional data. While Azure Analysis Services primarily uses tabular models, it still supports MDX for compatibility and for users accustomed to multidimensional concepts. You can use MDX to query the data model, retrieve measures, and slice and dice data.

Example MDX Query

SELECT
{[Measures].[Internet Sales Amount]} ON COLUMNS,
{[Product].[Category].MEMBERS} ON ROWS
FROM [Adventure Works]
WHERE ([Date].[Calendar Year].&[2023])

Using REST APIs

Azure Analysis Services provides REST APIs that allow you to programmatically interact with your Analysis Services instance. This is useful for building custom applications, automation scripts, or integrating with other services.

You can use the REST API to:

The primary endpoint for executing queries is:

POST https://api.asazure.windows.net/{server-name}/models/{database-name}/queries

Tip: For optimal performance with tabular models, DAX is generally recommended over MDX.

Tools for Querying

Several tools can be used to query Azure Analysis Services:

Note: Ensure you have the necessary permissions to connect to and query your Azure Analysis Services instance.

Best Practices