# Introduction to DAX Formulas & Measures for Power Pivot

Posted on January 28th, 2013 in Power Pivot - 13 comments

Last week, you saw an Introduction to Power Pivot for Excel. Today, lets talk about DAX formulas & measures for Power Pivot.

## What is a Measure?

A measure is a formula for the values area of Power Pivot table.

A measure can be implicit or explicit.

Implicit measures are created automatically when you drag and drop a field in to Power Pivot values area. For example, in last week’s introduction, we created an implicit measure for SUM of Sales by dragging and dropping the sales amount field in to values area of our power pivot table.

Explicit measures are created by you using New measure button in Power Pivot tab (or Calculated Field button in Excel 2013 Power Pivot tab). You can also create a measure in the Power Pivot window.

### Measures vs. Calculated Fields

They both refer to the same thing in the context of Power Pivot. Up to Excel 2010 Power Pivot versions, Microsoft used Measure as the official term.

Starting Excel 2013, Measures became Calculated Fields.

## So what is DAX then?

DAX stands for Data Analysis Expression. It is a special language we use to create measures in Power Pivot. Although it is a special language, it looks exactly like our regular Excel formulas. That means you can easily learn the DAX basics and create measures in no time.

Think of DAX as Excel Formula ++. An upgraded version of Excel formulas that can handle power pivot data and give you the calculations you want.

## Lets create a measure

### Step 1: Decide what the measure should do

The first step is to figure out the need for a measure. Lets say we want a measure to sum up total sales.

### Step 2: Launch New Measure screen

In Excel 2010: Power Pivot Ribbon > New Measure

In Excel 2013: Power Pivot Ribbon > Calculation Field > New Calculation Field

This will open below screen (screenshot for Excel 2013 shown below. Excel 2010 looks almost similar).

### Step 3: Give our measure a name

Lets call it Total Amount

#### Step 4: Write the DAX formula

The formula for summing sales is =SUM(sales[sale amount])

This formula looks exactly like an Excel formula!!!

As I mentioned before, the syntax, look & fell of DAX is just like Excel formulas. It is DAX’s power, flexibility & variety that outsmarts Excel formulas.

When you press OK, a new measure (Total Amount) will be created and attached to the Sales table in your power pivot data model. It looks like this,

Just drag and drop this measure in to values area of your pivot report. Instantly total sales amount will be calculated based on your report set up.

## Why bother creating a measure for such simple thing as SUM?

I know you would be asking this. It seems like a lot of trouble to create a measure, to just show the sum of sales amount. Well, SUM & COUNT are just tip of the DAX iceberg. The power of DAX formula engine is truly phenomenal. To prove it, lets play a small game.

Imagine how much time you would take to write a regular Excel formula or setting up a regular Pivot report to answer each of these questions:

• Count of distinct customers by region & Product category for month of May 2012
• Sum of sales made in weekends only by customer gender & product size for Q1, 2012
• Percentage of sales made in weekends (compared to total sales) by customer name
• Number of customers during lunch hours (between 12noon & 1:30 PM) by week day

Now, how would you feel if I tell you that using DAX, it will take less than 5 minutes to answer all these questions. 5 minutes!!!

And the beauty is, once we have a measure that tells us sales made in weekends, we can use it in any report:

• Sales in weekends by gender & product size – YES
• Sales in weekends by product category & month – YES
• Sales in weekends by year & season – YES

## Oh this is so tempting, teach me how, teach me now

Don’t worry. I am not going to leave you high & dry. I made a video (30 mins) explaining below topics:

• Introduction to DAX, measures & calculated fields
• Implicit vs. Explicit measures
• Creating a simple DAX measure
• Example DAX measures & explanation:
• Sum of sales
• Count of distinct customers
• Percentage of sales made in weekend

If all this sounds interesting, you would enjoy our upcoming online course on Power Pivot. If you want to know more about our class, please enter your name & email below. I will also send you 2 videos on Power Pivot.

## Do you DAX? Share your tips & experiences

It took me a while to wrap my head around the way DAX formulas work. I am still learning and struggling to come up with measures for every thing. But I find them very powerful & addictive. I am now able to create powerful analysis reports & dashboards for my clients, thanks to DAX formulas and Power Pivot.

 Can you calculate vacation days in a period? [Homework] Details about our Power Pivot Course [and a video for those of you not interested]
 Written by Chandoo Tags: advanced excel, calculated fields, DAX formulas, excel 2013, Learn Excel, measures, pivot tables, powerpivot, videos Home: Chandoo.org Main Page ? Doubt: Ask an Excel Question

### 13 Responses to “Introduction to DAX Formulas & Measures for Power Pivot”

1. Rahim says:

Thanks for sharing your 2nd post on PowerPivot,

**As is it still blocked in Pakistan

2. Rahim Zulfiqar Ali says:

My Question related to video:
If we have to calculate "Sales in Weekend" column in rolling months. Does the DAX Formula will work for all the months correctly ? How ?
Do we have to always find out when the first Monday comes in a particular month ? Example our database has months from Jul to Dec 2013.
I hope I have written my questions well to have your answers. Thanks in Advance. Looking forward to it and your course. But would be more happy If we (Visitors) can get 1 or 2 more lessons of PowerPivot on your Blog. 🙂

Thanks again

3. Shar says:

I'm loving the PowerPivot information!  Question though, we don't use Sharepoint at my work - is there any other way to share a PowerPivot workbook?

4. Rajeev Gautam says:

Mr. Chandoo,

I Request you please add given below topic in Power Pivot course.

1. How to Handle Many to Many Relationship
3. How to make Asymmatire Reports using Power Pivot
4. How to handle Banding Ranges Slab(0-10,11-15 etc)
5. Ratio and Percentage.

Regards,

Rajeev Gautam

5. [...] Introduction to DAX Formulas & Measures for Power Pivot [...]

6. [...] Chandoo.org on DAX Formulas and PowerPivot [...]

7. Kim Cook says:

Hi,

I am trying to view the DAX formula video and I have already signed up for the course. Everytime I try to view the video I get the sign up screen.

TIA

8. Heather says:

I need help. I have Tasks listed in the column labels quadrant in excel 2010, a date in the row label and values in the values quadrant. I created a new measure to average some time values for each of the 2 tasks. Now I want to create a mesaure to average the 2 averages. Both columns are labled the same thing "Avg Time (Minutes)". How do I get an average of those two columns when they are titled the same thing because of how it was done? Can I do a new measure and put in column names like a basic excel function (i.e. =Average(I8,J8)? Thanks!

9. Jacob Metzger says:

I am trying to view "Introduction to Measures & DAX" video, after I signup with my email, all I get is the course sign-up screen!

Jacob

10. Vinicius Martim says:

I've been trying to find the "Calculated Item" functionality of the conventional Pivot Table on the PowerPivot options and measures. But I haven't found any so far.
Does someone here has a hint about it?

11. Arturo says:

Estoy incursionando en el Power Pivot y quisiera saber cómo agrupo las fechas por ejemplo?. Gracias de antemano.
[Google translate] I'm dabbling in Power Pivot and let me know how I group the dates for example ?. Thanks in advance.

 Can you calculate vacation days in a period? [Homework] Details about our Power Pivot Course [and a video for those of you not interested]