Introduction to Data Analysis Expressions in Power BI

by | Updated November 2, 2020 | Power Platform

In this blog post, I would like to introduce something called Data Analysis Expressions, or DAX. DAX is a collection of functions, operators, and constants that allow you to create formulas and calculations that return values from objects that exist in your Power BI model. With DAX you can create columns, measures, and even your own tables. We’re going to keep it simple in this post and create a simple column and a measure. If you are familiar with creating expressions in Excel or in another BI tool, then DAX syntax will be easier to read but it doesn’t require any particular skill set.

Syntax

Sales Profit = ‘Sales'[SalesAmount] – ‘Sales'[Total Unit Cost]

This is a simple formula in DAX. It calculates the Sales Profit.

The syntax contains the following elements:

a) Just like in Excel, the equals (=) operator begins a DAX formula.
b) ‘Sales’[SalesAmount] is our column that contains revenue, which comes from the model in Power BI. Column references are surrounded by square brackets [].
c) In this example, we are subtracting two measures so we’ll use the subtraction (-) operator.
d) ‘Sales'[Total Unit Cost] is our column that contains cost, which also comes from the Power BI model.

A slightly more advanced formula is presented below:
Units Sold = sum(‘Sales'[Quantity])

a) Here the measure name is called Units sold.
b) The function SUM adds up all the Quantity numbers in the ‘Sales’[Quantity] column.
This formula adds all the values of Sales Quantity.

Creating a Formula in Power BI

Here are the steps on how to create a formula in Power BI. We’re going to create a simple column calculation called “Customer Name.” Notice that in there is no Customer Name in my Customers table.

Creating a column calculation called "Customer Name" in Power BI.

  1. Right-click on “Customers” and select “New column.” An area will appear below the tabs where you can enter a formula.
  2. Enter the following formula: Customer Name = ‘Customers'[LastName] & “, ” & ‘Customers'[FirstName]. To concatenate fields you can use the CONCATENATE function in DAX but that only accepts two arguments. Instead, we’re going to use the & operator.

The "Customer Name" column has been added to the Customers table in Power BI.

Notice that the Customer Name column is now added to the Customers table. When you click on Customer Name you’ll also notice that there is now a formula in the formula bar, which is the formula we created for this column.

To create a measure please follow these steps:

1. Right-click on your fact table and select “New Measure.”

Creating a new measure from a fact table in Power BI.

2. We don’t have a column that calculates Sales Amount in the model so we’ll create one now by using the formula Sales Amount = ‘Sales'[UnitCost] * ‘Sales'[Quantity] and entering it in the toolbar.

Creating a new Sales Amount column using a formula in Power BI.

 

In this blog post, we were introduced to DAX and created two simple column and measure calculations. This is one of many blogs you’ll see on DAX here since you’ll be using it every time you’re in Power BI creating calculations. In my next blog post, we’re going to cover an advanced topic of how to implement Power BI Time Intelligence functions using DAX.

Related Posts

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Upcoming Events

october

06oct10:00 am10:30 amPreview of D365 Business Central Fall Release Features and Functionality

06oct12:00 pm12:30 pmInsider's Guide to New Features Available in the Fall Release of D365 Finance and Supply Chain

07oct11:00 am12:00 pmConfab LIVE with Stoneridge - Dataverse and Dynamics in Review – Let’s Get Technical

13oct12:00 pm12:30 pmWave 2 Release – What’s Coming for Dynamics 365 Sales and Customer Service

21oct11:00 am12:00 pmConfab LIVE with Stoneridge - Dataverse and Dynamics in Review – Let’s Get Functional

26oct(oct 26)9:00 am28(oct 28)5:00 pmStoneridge Connect Leadership and Community Conference

november

04nov11:00 am12:00 pmConfab LIVE with Stoneridge - Challenging the Development Paradigm

About Stoneridge
Stoneridge Software is a unique Microsoft Gold Partner, with emphasis on partner. With specialties in Microsoft Dynamics 365, Microsoft Dynamics AX, Microsoft Dynamics NAV, Microsoft Dynamics GP and Microsoft Dynamics CRM, we focus on attracting the most knowledgeable experts in the field to our team, and prioritize delivering stellar solutions with maximum impact for your business. At Stoneridge, we are deeply committed to your results. Each engagement is met with a dedicated team, ready to provide thorough, tailored, and expert service. Based in Minnesota, we intentionally “step into your shoes,” wherever you are. We focus on what you care about, and develop trusting, long-term relationships with our clients.

Subscribe To Our Blog

Sign up to get periodic updates on the latest posts.

Thank you for subscribing!

X