Thursday, July 4, 2019

SSAS Tabular Compatibility 1400 : Use SQL query to import data

In SSAS Tabular with compatibility level 1200, you can import data either from table or by specifying query using second option shown in the following snap however same option is not present in SSAS Tabular with compatibility level 1400.



So what to do if you want to import data using a query instead of importing table or view in SSAS Tabular with compatibility level 1400. You can achieve this by using following steps.

1. Open the "Tabular Model Explorer" and right click on "Expressions" folder and click on "Edit Expressions" option.







2. When you click on "Edit Expressions" option, it will open "Power Query Editor" window. Navigate to "Query" -> "New Query" and then click on "Blank Query" option.





3. Under formula bar, type like the following syntax where DataSourceName is the name of your data source and mention query as per your requirement.

= Value.NativeQuery(#"DataSourceName", "SELECT * FROM Table")




4. Once you click on Enter button, you will be able to see data below formula bar. Right click on newly created expression. here in my case, I have renamed it to DimEmployee. And click on "Create New Table" option.



5. Once you click on "Create New Table" and navigate to "Tabular Model Explorer", you can see new table being created under "Tables" folder.