Excel Power Pivot & Power Query For Dummies. Michael Alexander

Читать онлайн книгу.

Excel Power Pivot & Power Query For Dummies - Michael Alexander


Скачать книгу
this point, your diagram will look similar to Figure 2-9. Notice that Power Pivot shows a line between the tables you just connected. In database terms, these are referred to as joins.

Snapshot of the Power Pivot diagram shows join lines between tables.

      FIGURE 2-9: When you create relationships, the Power Pivot diagram shows join lines between tables.

      The joins in Power Pivot are always one-to-many joins. This means that when a table is joined to another, one of the tables has unique records with unique index numbers (CustomerID for example), while the other can have many records where index numbers are duplicated.

      Notice in Figure 2-9 that the join lines have arrows pointing from a table to another table. The arrows in these join lines will always point to the table that has the duplicated index. In this case, the Customers table contains a unique list of customers, each having its own unique identifier. No CustomerID in that table is duplicated. The Invoice header table has many rows for each CustomerID; each customer can have many invoices.

To close the diagram and return to seeing the data tables, click the Data View command in the Power Pivot window.

      Managing existing relationships

      If you need to edit or delete a relationship between two tables in your data model, you can do so by following these steps:

      1 Open the Power Pivot window, select the Design tab, and then select the Manage Relationships command.

      2 In the Manage Relationships dialog box, shown in Figure 2-10, click the relationship you want to work with and click Edit or Delete.If you click Edit, the Edit Relationship dialog box (shown in Figure 2-11) appears. The columns used to form the relationship are highlighted. Here, you can redefine the relationship by simply selecting the appropriate columns. You can also use the Active check box to disable or enable the relationship.

Snapshot of using the Manage Relationships dialog box to edit or delete existing relationships.

      FIGURE 2-10: Use the Manage Relationships dialog box to edit or delete existing relationships.

      

In Figure 2-9, you see a graphic of an arrow between the list boxes. The graphic has an asterisk next to the list box on the left, and a number 1 next to the list box on the right. The number 1 basically indicates that the model will use the table listed on the right as the source for a unique primary key.

      Every relationship must have a field that you designate as the primary key. Primary key fields are necessary in the data model to prevent aggregation errors and duplications. In that light, the Excel data model must impose some strict rules around the primary key.

      You cannot have any duplicates or null values in a field being used as the primary key. So the Customers table (refer to Figure 2-9) must have all unique values in the CustomerID field, with no blanks or null values. This is the only way that Excel can ensure data integrity when joining multiple tables.

Snapshot of using the Edit Relationship dialog box to adjust the tables and field names that define the selected relationship.

      FIGURE 2-11: Use the Edit Relationship dialog box to adjust the tables and field names that define the selected relationship.

      Using the Power Pivot data model in reporting

      After you define the relationships in your Power Pivot data model, it’s essentially ready for action. In terms of Power Pivot, action means analysis with a pivot table. In fact, all Power Pivot data is presented through the framework of pivot tables.

      In Chapter 3, you dive deep into the workings of pivot tables. For now, dip just a toe in and create a simple pivot table from your new Power Pivot data model:

      1 Activate the Power Pivot window, select the Home tab, and then click the Pivot Table command button.

      2 Specify whether you want the pivot table placed on a new worksheet or an existing sheet.

      3 Build out the needed analysis just as you would build out any other standard pivot table, using the Pivot Field List.

Snapshot shows a Power Pivot-driven pivot table that aggregates across multiple tables.

      FIGURE 2-12: You now have a Power Pivot-driven pivot table that aggregates across multiple tables.

      In the days before Power Pivot, this analysis would have been a bear to create. You would have had to build VLOOKUP formulas to get from Customer Number to Invoice Number, and then another set of VLOOKUP formulas to get from Invoice Numbers to Invoice Details. And after all that formula building, you still would have had to find a way to aggregate the data to the average unit price per customer.

      Конец ознакомительного фрагмента.

      Текст предоставлен ООО «ЛитРес».

      Прочитайте эту книгу целиком, купив полную легальную версию на ЛитРес.

      Безопасно оплатить книгу можно банковской картой Visa, MasterCard, Maestro, со счета мобильного телефона, с платежного терминала, в салоне МТС или Связной, через PayPal, WebMoney, Яндекс.Деньги, QIWI Кошелек, бонусными картами или другим удобным Вам способом.

/9j/4AAQSkZJRgABAQEBLAEsAAD/7SwuUGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAA8cAVoAAxsl RxwCAAACAAAAOEJJTQQlAAAAAAAQzc/6fajHvgkFcHaurwXDTjhCSU0EOgAAAAAA5QAAABAAAAAB AAAAAAALcHJpbnRPdXRwdXQAAAAFAAAAAFBzdFNib29sAQAAAABJbnRlZW51bQAAAABJbnRlAAAA AENscm0AAAAPcHJpbnRTaXh0ZWVuQml0Ym9vbAAAAAALcHJpbnRlck5hbWVURVhUAAAAAQAAAAAA D3ByaW50UHJvb2ZTZXR1cE9iamMAAAAMAFAAcgBvAG8AZgAgAFMAZQB0AHUAcAAAAAAACnByb29m U2V0dXAAAAABAAAAAEJsdG5lbnVtAAAADGJ1aWx0aW5Qcm9vZgAAAAlwcm9vZkNNWUsAOEJJTQQ7 AAAAAAItAAAAEAAAAAEAAAAAABJwcmludE91dHB1dE9wdGlvbnMAAAAXAAAAAENwdG5ib29sAAAA AABDbGJyYm9vbAAAAAAAUmdzTWJvb2wAAAAAAENybkNib29sAAAAAABDbnRDYm9vbAAAAAAATGJs c2Jvb2wAAAAAAE5ndHZib29sAAAAAABFbWxEYm9vbAAAAAAASW50cmJvb2wAAAAAAEJja2dPYmpj AAAAAQAAAAAAAFJHQkMAAAADAAAAAFJkICBkb3ViQG/gAAAAAAAAAAAAR3JuIGRvdWJAb+AAAAAA AAAAAAB

Скачать книгу