D Functions and Pivot emulation
- 03:12
Understand how to emulate a pivot table using D Functions and Data Tables
Glossary
Data TablesTranscript
So while we're on the topic of pivot tables, it's useful to have a little look at D functions combined with data tables. And effectively this emulates what a pivot table does. Let's have a look at example and see how it works.
So I've set up my pivot that I would like to produce. So I've got a list of products in our rows and a list of regions in our columns. I've set up the criteria that I want up here for the D function. And we are gonna use a D sum to calculate the total amount of sales for each of the products in each of the regions. So the first thing is this is going to be our data table. So this area here. So as you will have learned in the data tables video, if you haven't looked at that one yet, then please go and search that one out. Then we need to put the formula in the top left hand corner of our data table. So equals, D sum, open bracket.
And the first item it wants is our database. So that's what we're going to give it.
And we are going to absolute reference that. So we're gonna make sure that's an absolute reference. Comma, the next thing it wants is the field. So we said that's gonna be our sales amount. So we're gonna go and choose our sales amount. Again, fixed, comma. And the final part is the criteria that we would like for our D sum function. Again, need to fix that. That doesn't change. Close the brackets. Press enter. So there is the single calculation for eyeliner in the east. Now what we're gonna do now is we're going to select the area we want for our data table and trigger our data tables function. So that's Alt DT. Let's move the dialogue box out the way for you here. So the row input cell, remember, is the thing that changes across the rows. So this is gonna be our location. The column input cell is the thing that changes down the column. So that's gonna be our product. And once we've got those two cells filled in, we click okay. And now we are looking at a completed data table for the D sum function, and you can see how it emulates what we could achieve via pivot. So that's one alternative. So what's the difference between the pivot table
Well, the data table's dynamic. So if things change about our database, then these figures will update. Whereas you'll remember with a pivot table, we have to refresh the data. But that's an alternative to using a small pivot table.