# Introduction to DAX Formulas & Measures for Power Pivot

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 **D**ata **A**nalysis E**x**pression. 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,

### Step 5: Add this measure to your Power Pivot report

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

All without any additional work!

## 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
- Sales made in weekend
- Percentage of sales made in weekend

## How can I learn more?

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.

[Click here in case you are not able to see the sign-up form.]

## 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.

**What about you?** Do you play with DAX often? What is your experience like? *Please share your ideas, tips & suggestions in comments.*

### Do you want to be awesome in Excel?

**Here is a smart way to become awesome in Excel**. Just signup for my Excel newsletter. Every week you will receive an Excel tip, tutorial, template or example delivered to your inbox. What more, as a joining bonus, I am giving away a 25 page eBook containing **95 Excel tips & tricks**. Please sign-up below:

Your email address is safe with us. Our policies

### Leave a Reply

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

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

Thanks for sharing your 2nd post on PowerPivot,

Please can you share Video link other than Youtube. Thanks

**As is it still blocked in Pakistan

@Rahim... You are welcome. The video is not on youtube. You will be able to see it once you confirm your email address here: http://chandoo.org/wp/resources/learn-power-pivot-for-excel/

Thanks !

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

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?

Mr. Chandoo,

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

1. How to Handle Many to Many Relationship

2. Non Additive and Semi Additive Calculation

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

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

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

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

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!

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!

Please help!

Jacob

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?