Parameters for DAX Queries

This topic illustrates how to pass parameter values in an XMLA structure to a DAX query statement.

Parameters in XMLA and DAX queries

A well-defined DAX query statement would benefit enormously by being able to be parameterized and then used, over and over, with just changes in the parameter values.

The Execute Method (XMLA) method, in XMLA, has a Parameters Element (XMLA) collection element that allows parameters to be defined and assigned a value; within the collection, each Parameter Element (XMLA) element defines the name of the parameter and a value to it.

The DAX query syntax allows you to reference XMLA parameters by prefixing the name, of the parameter, with an @ character. Hence, any place in the syntax where a value is allowed it can be replaced with a parameter call. However, one thing needs to be remembered: all XMLA parameters are typed as text.

Warning

Parameters defined in the parameters section and not used in the <STATEMENT> element generate an error response in XMLA.

Warning

Parameters used and not defined in the <Parameters> element generate an error response in XMLA.