Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Microsoft Tabular Modeling Cookbook

You're reading from   Microsoft Tabular Modeling Cookbook No prior knowledgeof tabular modeling is needed to benefit from this brilliant cookbook. This is the total guide to developing and managing analytical models using the Business Intelligence Semantic Models technology.

Arrow left icon
Product type Paperback
Published in Dec 2013
Publisher Packt
ISBN-13 9781782170884
Length 320 pages
Edition 1st Edition
Arrow right icon
Author (1):
Arrow left icon
Paul te Braak Paul te Braak
Author Profile Icon Paul te Braak
Paul te Braak
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Getting Started with Excel FREE CHAPTER 2. Importing Data 3. Advanced Browsing Features 4. Time Calculations and Date Functions 5. Applied Modeling 6. Programmatic Access via Excel 7. Enterprise Design and Features 8. Enterprise Management 9. Querying the Tabular Model with DAX 10. Visualizing Data with Power View A. Installing PowerPivot and Sample Databases Index

Adding fields to tables

The model designer is often required to add additional fields to tables, so that the information presented to the user is better suited for decision-making purposes. This can include creating new fields that are combinations of other fields within the same table or a calculation that is dependent on data in another table. This recipe looks at the first of these options to create new fields that use other fields within the same table.

Getting ready

The model used in this recipe starts with the model that was created in the previous recipe Using tabular relationships to filter data.

How to do it…

  1. Switch to the data view in the PowerPivot window and select the Products table. Select the Colour column by right-clicking on the column header and selecting Insert Column from the pop-up menu (note that the entire column must be selected). The new column is inserted to the left of the Colour column. Change the name of the CalculatedColumn1 to Product Name WC (product name with code).
    How to do it…
  2. Enter the following formula into any cell of the new column.
    =[Product Name]&" (" & [Product ID] & ")"

    All rows of the table will be automatically populated.

  3. Switch to the Sales table. Double-click on the header row of the last column (the current header is Add Column) and change the name of the column to total_profit. Enter the following formula into any cell of the Profit column with the format of the column as currency.
    =[total_price]-[unit_cost]-[tax]

    Tip

    The designer has two built-in functions that enable the easy creation of formulas. If the formula is being typed, an intellisense window will open in the formula bar, and show a list of objects that match what is being typed. Simply navigate to the desired column (or cell in the measure grid) and start typing, then press return to use the provided intellisense option (you can use arrow keys to select a function, table and column). Alternatively, a column or table name can be included in the formula by clicking on the column or table while the formula is being typed.

How it works…

This recipe introduces Data Analysis Expressions (DAX) as the language that is used in tabular modeling. From this recipe, we can see that the DAX language is very similar to an Excel calculation (there are some noticeable differences which are addressed in chapters). Also, note that in DAX, columns are referred to instead of cells. Furthermore, many Excel functions work exactly the same in DAX as they do in Excel.

In calculating the value for each row, a special filter is applied in the calculation. In these examples where the fields being used in the formula reside on a single row, the filter automatically restricts the value to that of the row. The application of filtering in this manner is commonly referred to as a row filter or a row filter context.

You have been reading a chapter from
Microsoft Tabular Modeling Cookbook
Published in: Dec 2013
Publisher: Packt
ISBN-13: 9781782170884
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image