What is DAX in Power BI?
Business intelligence is a critical aspect of any business. Along the development path of the business intelligence tools, Power BI has stood out as one of the most versatile tools. Power BI, developed by Microsoft is a cloud-based business analysis suite that comes packaged with tools for performing calculations, data analysis, and data visualization. It is a drag-and-drop tool that allows you to select your desired field for analysis and drop in on the Power BI dashboard to perform analyses and generate insights. If you have undertaken the PowerBI training, you are probably familiar with PowerBI components including:
- Power Query
- Power Pivot
- Power View
- Power Map
- Power BI desktop
- Power BI website
- Power Q & A
Power BI features
- An interactive dashboard
- Aesthetic designs
- Compatibility with databases
- Fast and easy creation of charts, dashboards, and Power BI reports
- Real-time alerts and visualizations
- Works well with other Microsoft tools like Azure, SQL Server, and Windows voice assistant Cortana
What is DAX in Power BI?
DAX (Data Analysis Expressions) is a formula expression language used in BI tools like Power BI Desktop, PowerPivot, SQL Server Analysis Services (SSAS) to define custom calculations and analysis for the tabular data models. DAX in itself is a collection of functions, constants, and operators that are applied to an expression or a formula to perform dynamic aggregations and return one or more values. Ideally, DAX was designed to help extract more information from data that already exists in your model. Therefore, DAX helps data analysts to make the most out of the data sets that they have.
DAX includes some of the functions used in Microsoft Excel formulas as well as other functions that can be applied to relational data to perform dynamic aggregation. Overall, DAX is simple and easy to learn.
Importance of Data Analysis Expressions (DAX)
As we have already seen, Power BI is used to run reports and present insights in the form of visuals from a company’s datasets. Power BI is built with a calculation engine that automatically performs calculations on data to generate reports with the desired insights. However, where more advanced analysis needs to be done on data, Power BI drag-and-drop function is not adequate. This is where DAX comes in. DAX expressions allow you to perform advanced calculations and data analysis on existing data sets. Creating DAX expressions is similar to the way formulas are created in Microsoft Excel.
DAX functions allow you to perform calculations on the data organized in the tables in your data model. As we have already seen, some DAX formulas resemble those used in Excel in name and functionality but have been adjusted to be used on DAX tables in the data models. Other DAX functions are designed to be applied to relational data. Still, others are used for performing dynamic aggregations.
Steps to creating DAX formulas
To create a DAX function:
- Begin by typing the equal (=) sign
- Type the function name or expression
- Type in the required values or supply arguments to the function by selecting the appropriate one from the dropdown list. PowerBI lists all functions in a dropdown list in each category which makes it easy to select the function that you want.
- Close off parentheses. Also, check that referencing is correct on your columns, tables, and values.
- Press enter to apply the formula to your data model
Types of DAX calculations
Power BI has two main categories of calculations using DAX. These are:
- Calculated columns
- Calculated measures
The data modeling tab includes a formula bar in which you can type your formula to perform your calculations. Both columns and measures use DAX expressions.
DAX has at least 250 functions. Some commonly used DAX function categories include:
- Date and time functions are used to create time and date calculations. These are similar to the Excel time and date formulas. Examples include DATE, HOUR, NOW, and WEEKDAY.
- Filter functions that are applied on data models to return specific data types filtered by related values. Examples include ALL, ALLEXCEPT, ALLSELECTED, and CALCULATE.
- Aggregation functions that are applied to return scalar values. Examples include MIN, MAX, AVERAGE, and SUM.
- Financial functions are the same as those used in Microsoft Excel. They are used in formulas that perform financial calculations such as rate of return. Examples include ACCRINT (accrued interest), ACCRINTM (accrued interest on maturity), and DISC (discount rate for security).
- Logical functions are applied to expressions to return information about the values in the expressions. Examples include IF, AND, OR, and NOT.
- Math and trigonometric functions are also similar to Excel math and trig functions with minor differences in the DAX numeric data types. Examples include ABS, ASIN, COS, and ACOS.
- Other functions are special functions that perform very unique functions that cannot be classified under any of the categories. Examples include EXCEPT, GROUPBY, VALUE, TRIM, and UPPER.
- Relationships management functions are applied to tables to return values on relationships. Examples include RELATEDTABLE, USERELATIONSHIP, CROSSFILTER, and RELATED.
- Statistical functions perform aggregations. Examples include BETA.DIST, CONFIDENCE.NORM, MEDIANX, and BETA.INV.
- Table manipulation functions manipulate existing tables or return tables. Examples include ADDCOLUMNS, CROSSJOIN, DATATABLE, and GROUPBY.
- Text functions are used to manipulate strings. Examples include REPLACE, SEARCH, FIXED, and UPPER.
- Time intelligence functions perform calculations together with aggregations to build comparisons and relationships between time periods. Examples include LASTDATE, NEXTDAY, NEXTMONTH, and NEXTQUARTER.
DAX was designed to be a solution to advanced data challenges in Power BI. DAX comes with higher data analysis and calculations capabilities. If you are familiar with basic Power BI concepts and Excel formulas, grasping the DAX function will be much easier for you. DAX enables businesses to make the most of the data sets available to them. This is certainly way beyond the capacities of Power BI which is limited to drawing reports from data and creating visualizations. Thus, DAX brings out the powerful data analysis capabilities of Power BI.