Understanding Aggregation in The Tableau View & Calculated Fields AGG

preview_player
Показать описание

Understanding aggregation in tableau in order to describe aggregation we're going to be talking about measures so a measure is something like sales profit or quantity a field that can be added up or aggregated if I drag a measure onto text in tableau it adds it up defaulted to a sum so now on my screen we're showing 2.2 million and that's the sum of sales in my entire data source I can change that aggregation from the sum to other aggregations like average median count minimum or maximum there are others as well let's change it to average

What Tableau is doing here is taking every single Row in the data every single sales value and averaging it up to a value of 229.9 Tableau Aggregates everything at the level of detail in the view right now I only have average sales and no other dimensions by bringing in a dimension like region and put it on rows Tableau is going to aggregate sales so take an average of sales for each region So within the west region the average sales is 226 and in the East it's 238. It doesn't matter where you put your pills it will still aggregate it I moved sales up to columns and we have a bar chart of average sales now within calculated fields aggregations are shown a bit differently click on the drop down and I'm going to create a calculated field called sum of sales and I'm simply going to write sum of sales

Click apply I'm going to leave this on the screen i'll bring some into the view

And replace my sales value you'll see that the sum of sales for West is 725 000. I no longer have the ability to change sum of sales to a different aggregation I cannot change it into an average a median or Max in The View if I wanted sum of sales to be an average I would need to change it within a calculated field let's change this to average click apply and the sum of sales is now set to be the average and each region shows which the average is for that region let's do one more calculation I'm going to click the drop down create a calculated field and call this profit ratio instead of writing sum this time I'm just going to pass in the variables so I'm going to do profit divided by sales that's going to give you profit ratio

Click apply I'm going to leave that there

If I don't use any aggregations in the calculated field and drag it onto the view I can use an aggregation here give me the option to use a sum an average median and so on because I didn't use any aggregations in here so what Tableau is doing here is taking profit divided by sales for every single Row in your data and then after you bring it into the view it's adding it all up that's not how profit ratios are calculated so in this case I want to use sum of profit divided by sum of sales

Before I click apply you'll notice that my pill will turn red when I click apply it's not an error if I click apply but I have aggregations in my calculated field I can no longer sum it up Tableau has already tried to some profit ratio up because that's what I had to set to before so if you ever see a red pill just remove it and drag it back in now I have the actual profit ratio which is sum of profit divided by sum of sales but Tableau does is two steps takes the sum of profit for each region adds it up and takes the sum of profit sum of sales for each region adds it up and divides the two there are times that you want to do calculations at the row level but most commonly you'll be using aggregations in calculated fields and that's how to aggregate data in Tableau hope this helps [Music]

Now
Рекомендации по теме