We have been writing DAX queries using MDX Query Editor whenever we need to do something with Analysis Services Tabular Model databases (Read my old post on this: How to write SELECT for Analysis Services Tabular using DAX). Now, with this month Management Studio release (release number 17.0), we have a new Query Window for DAX.
You can download the latest at https://docs.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms
Once the new release is installed, you should see the icon and menu item for DAX Query Window;
Writing DAX Queries
Here is an example of DAX queries that can be written. As you see, first statement uses SUMMERIZE function to produce a result that shows sales by day of the week and product. Second query creates a measure using DEFINE MEASURE and uses it again with another query.
EVALUATE SUMMARIZE(Sales_201501, Sales_201501[CalendarDayOfWeekLabel] , Sales_201501[ProductName] , "Sales", SUM(Sales_201501[SalesAmount])) GO DEFINE MEASURE Sales_201501[NewSales] = SUMX(FILTER(Sales_201501, Sales_201501[IsWorkDay]="WeekEnd") , Sales_201501[SalesAmount]) EVALUATE SUMMARIZE(Sales_201501, Sales_201501[CalendarDayOfWeekLabel] , Sales_201501[ProductName] , "Sales", Sales_201501[NewSales])
Here is the result of it;
No comments:
Post a Comment