Using EVALUATE in DAX queries
If you need to query the data in a tabular model, then you can use the EVALUATE
function. The Evaluate
function is used on a table to return the result set as a table. It is similar to using Select * in T-SQL
to return all columns and rows from a table. The EVALUATE
function has a required syntax of EVALUATE 'tablename'
.
How to do it...
Connect to the CHAPTER_9_DAX database in SQL Server Management Studio.
Right-click on Databases and select New Query | MDX to create a new MDX query window.
In the new window, use the
EVALUATE
function to return the data in a table. Type in the expression and then press F5 to run the command:EVALUATE 'WEATHER_T'
To extend this formula a bit more, you can add an order by clause to change the sort order returned in the query. Add an order by clause on the next line to sort the data on the first column in descending order:
ORDER BY 'WEATHER'.[WEATHER] DESC