8 Replies Latest reply on May 2, 2018 1:14 AM by naresh.suglani.0

# Percentage calculation of product sales as a percentage of total sales?

Hi all, I've attached an example excel file. I need to calculate the % sales of each product in the "Product Name" column based on total sales which are in the "Sales" column.

I have included a pivot table showing how the % breaks down. The data file contains a snapshot for week 15 and year 2018, but in the database I'm using, all weeks and years are present so would I be able to filter on week/year in the resulting tableau workbook?

• ###### 1. Re: Percentage calculation of product sales as a percentage of total sales?

Hi

is this what you are looking for?

this is done with a table calculation - I added some data to show you how to do this over a couple of week

this can also be done with and LOD expression

they return this

One final comment - if you have control of the data I would highly recommend you bring in real dates in date format vs text data that represents a year or a week

Jim

If this posts assists in resolving the question, please mark it helpful or as the 'correct answer' if it resolves the question. This will help other users find the same answer/resolution.  Thank you.

• ###### 2. Re: Percentage calculation of product sales as a percentage of total sales?

Hi Naresh,

put these two fields in the column and row then right click on SUM(Sales) then follow these steps

The data will be shown like this:

And yes week number and the Year number can be used as the filter.

You can use them directly or first by changing the data type of Year and Week number to "Date" and then use them as filter by Right clicking and then show as filter and choosing Year and Week number respectively.

Thanks,

Lovepreet

• ###### 3. Re: Percentage calculation of product sales as a percentage of total sales?

Hi Jim thanks for your input I tried that but it didn't give me the expected result. I was actually doing this to populate a waffle chart example I saw on LinkedIn but when I changed to my database it wouldn't display the correct percentage. It's currently fixed at 10%.

I have attached the workbook here which includes a table showing the expected percentages for each product name.

When the filter is set to Standard the waffle chart should display (both graphically and numerically) 54%.

I appreciate you may not be familiar with this type of chart but I'm hoping that either you or Lovepreet above can help me out as it's a nice Viz to use.

• ###### 4. Re: Percentage calculation of product sales as a percentage of total sales?

Here is what came up when I opened your file

also - wish you had taken the time to attach the file and the explanation to your first post - to provide the information that was need to get you the solution that you wanted

Jim

• ###### 5. Re: Percentage calculation of product sales as a percentage of total sales?

Apologies Jim, I was a bit tight on time when I initially posted and was hoping I could have found a fix by simply attaching the excel data. I had assumed that your solution and that from Lovepreet could have been easily applied to this waffle chart example. I'm now attaching the packaged workbook together with the 2 data files.

Kind regards,

Naresh

• ###### 6. Re: Percentage calculation of product sales as a percentage of total sales?

Anyone please? This has been bugging me and I'm not sure if it's down to an issue connecting with MC Access. I have tried various SUM and TOTAL calculations. The % shows correctly in a table but not on the waffle chart. Strange.