Search code examples
excelpivot-table

How to compute a percentage in pivot table in Excel based on the combination of column & line


I want to compute the percentage of Action that are Done by Category on line axis combined with Level on column axis in a Pivot Table

Action Category Level Done
1 Category 1 Level 1
2 Category 1 Level 2 x
3 Category 1 Level 3
4 Category 1 Level 3
5 Category 2 Level 3
6 Category 2 Level 3 x
7 Category 3 Level 1
8 Category 3 Level 1
9 Category 3 Level 1
10 Category 3 Level 1
11 Category 3 Level 1 x
12 Category 3 Level 2
13 Category 3 Level 3
14 Category 3 Level 3

Resulting in the following Pivot Table :

Line Level 1 Level 2 Level 3
Category 1 100%
Category 2 50%
Category 3 20%

In the Pivot Table of Excel, the only computation option available for the Done field is to compute the Percentage of the Line or the Percentage of the Column. There is no combination of both Line & Column.


Solution

  • Assuming your table is placed in the range A1:D15 (and there are no other data below it), place in cell E2 this formula:

    =(IF(COUNTIFS(B$1:B2,B2,C$1:C2,C2,D$1:D2,"x")=1,COUNTIFS(B:B,B2,C:C,C2,D:D,"x")/COUNTIFS(B:B,B2,C:C,C2),0))
    

    Drag the formula down accordingly. Choose the header you like (say "percentage") and write it in cell E1. Create a pivot table similar to the one you have putting level in the columns, category in the rows and percentage in the values. Set values as "sum" and its format as percentage (you can do so by selecting the values area, right-clicking and choosing cells format).

    enter image description here