
46 Practical PowerPivot & DAX Formulas for Excel 2010
and the Related Lookup Column. The table is on the one side of a relationship and the
column is its primary (lookup) key. If you get the tables in the wrong order, PowerPivot
will automatically reverse them for you. For the Excel/data feed import only:
1. Click the Design tab and choose Create Relationship.
2. Implement all of the five necessary relationships from the preceding list.
Adding Columns
It’s quite possible that your source data does not include everything you want in
a subsequent pivot report (table or chart). For example, you may wish to analyze
and compare sales amounts by year. Neither the sales amount nor the year exists
in our source data. It’s also likely that it does not include the necessary degree of
denormalization. Denormalization is a process of reassembling data from a segmented
and normalized transactional database to help in your BI analysis. Here, you might
want to analyze by both category name (that is, product categories) and product name
at the same time. Currently, the product name and the category name are in two
separate tables (Products and Categories). If you were to have them both in one table,
your pivot reports will display the correct data—for example, the product Chai will
appear under the Beverages category and not under the Seafood category. If you are
able to implement these and similar changes, you are creating business intelligence
from often-unfriendly source data that may originate from many different sources.
PowerPivot makes this (and more) easy. Not only does it centralize and assemble data,
it helps you to transform that data into intelligence.
One powerful, yet straightforward, way to change your data into intelligence is to
create new columns in your PowerPivot tables. You are helped in this by the versatility
of DAX formulas. In the upcoming example, we are going to use DAX three times. In
this chapter, the DAX examples are to give you a taste and get you started (and possibly
excited!). There are many more examples in Chapter 3, and a whole part of this book
(Part II) is devoted to DAX. Let’s turn our data into real business intelligence by adding
the sales amount, and the year an order was made, and by having product names and
category names together. If you are working along, you can use the PowerPivot tables
imported from either Excel, Access, SQL Server, or a data feed (or a combination of
two or more of these sources, if you’ve been experimenting). PowerPivot makes the
source data transparent.
To add business intelligence to PowerPivot using DAX:
1. Click on the tab for the Order Details table to make it current.
2. You’ll see an empty column at the right of the table with the heading Add
Column. Click anywhere in this column and type the following DAX formula