DAX Coding Inside Tabular Editor 3


This tutorial will talk about DAX coding in Tabular Editor 3. You’ll learn how to create DAX queries and understand how it can be used as a query language. You’ll also learn how to utilize and maximize queries to obtain certain data from large tables.

DAX Coding For Local Sessions Within A Query

Tabular Editor has a feature that allows you to create queries for local sessions. To create a DAX query, go to the File toolbar. Click New and then select DAX Query. With that, you can now create measures that are local to the query.

First, input DEFINE and then MEASURE. Next, specify the table where you want to create the measure and name it Total Sales 2. Provide the code for the Total Sales measure by using the SUMX function. Input the Sales table as the first argument and input Quantity multiplied by the Unit Price as the second argument.

Next, define another measure and name it Total Sales Online. Use CALCULATE and input Total Sales 2 as its first argument. Then, input Sales Channel as a filter in the second argument.

To return a result, use the EVALUATE function. Inside that function, use SUMMARIZECOLUMNS for the Product Name, Total Sales 2, and Total Sales Online.

DAX CodingDAX Coding

You can see that two measures are created. These measures are local to the query and don’t appear in the TOM Explorer and Power BI. After formatting the code, this is what it will look like.

DAX CodingDAX Coding

From there, run the code by pressing F5. After that, you’ll see a table with the Product Name, Total Sales 2, and Total Sales Online columns.

DAX Coding For Local Columns Within A Query

You can also create query columns that are local to this session of Tabular Editor. Go to the File toolbar and create a new DAX query. Next, input the following code and press F5.

DAX CodingDAX Coding

After running the code, you’ll see new columns inside the ProductsData table. However, if you go back to Power BI, the new columns will not exist.

You can use the new columns for grouping or filtering. For this example, use the FILTER function to check how many values are greater than the value of line 11 in the table.

DAX CodingDAX Coding

If you run the code, the table will only show you the rows that are greater than the given value.

If you want to add an equal sign in the code, the table will show you the rows that are equal and greater than the given value.

DAX CodingDAX Coding

***** Related Links *****
Tabular Editor Power BI: Version 3 Review & Tutorial
DAX Query Optimization Techniques And Lessons

Using Text Functions In Power BI – DAX Tutorial

Conclusion

DAX queries can be easily created inside Tabular Editor 3. Coding inside the editor will make data development faster because you can open and view tables as a guide. The queries can be loaded to Power BI for your data models and reports. If you want to learn more about DAX queries and Tabular Editor, you need to practice more on creating DAX functions.

Enterprise DNA Experts

author avatarauthor avatar

Sam is Enterprise DNA’s CEO & Founder. He helps individuals and organizations develop data driven cultures and create enterprise value by delivering business intelligence training and education.



Source link

Be the first to comment

Leave a Reply

Your email address will not be published.


*