3 Replies Latest reply on Jun 17, 2017 6:27 PM by Alex C.

# replicating pivot tables in Tableau

Hi,

I am new to tableau.

I have an Excel sheet in which, every line has the number of fans of a certain Facebook page on a certain day. In total I have about 700 pages. Data is updated every day, but since the list of pages gets updated over time, different pages might have a different number of data points.

My problem is that I want to aggregate these pages, for instance, by type (example all soft drink pages), and find out how many fans, on average, the soft drink category has had over a given period.

If I use the "average" function I get the average size of a single page of the soft drinks category (Tableau averages by number of pages and by number of days in which the data was collected), while if I use the sum function of course I get the sum of all the days, which is way to much. I would need to divide that total by the number of days of data I have for each category, but how.

On Excel I build an intermediary pivot table (and of course loose the detail of the day).

Thanks so much

fabio

• ###### 1. Re: replicating pivot tables in Tableau

Here's one idea: Let's say the # of fans is stored in a Fans field. Then to calculate the number of days that you have data for, you'd do something like WINDOW_SUM(COUNT([Fans])). If you have your Category on the Rows shelf, the default calculation of Table (Across) will get you a count of all days with data per page, and partitioned by the Category.

• ###### 2. Re: replicating pivot tables in Tableau

Thanks so much!

• ###### 3. Re: replicating pivot tables in Tableau

Hi there, I have faced the same challenge. I came up with a Tableau model that is very close to an Excel pivot table and wrote a tutorial here: https://assemblinganalytics.com/post/tableau-pivot-table-element-build-an-excel-pivot-table-in-tableau/

The trick is to use interchanging columns leveraging parameters. This is a result I have in production and users do like it, you can of course further enhance by:

• Making more pleasing to the eyes
• Adding charts and graphs using the dashboard actions