# How to add a formulae on Grouped Fields in Pivot Table

#### sohailausaf353

##### New Member
Dear All,

I have had to Group items extracted from 13 different Income Statements which contained items differing slughtly from each other eg but with Sales, Sale, Net Sale, Income, etc,etc.

Now I would like to Perform a calculation of a Net profit Margin, which would have the Net Profit divided by Sales. In this case I would like to use the Grouped Net profit divided by Grouped Sales. Can this be done and how.

Thanks

### Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
A couple things for the accounting side of things.

If they are all named differently, are these sales or revenue sources from other departments?

First off, you could create another sheet where you source these things around. Bring the items in and use a VLOOKUP() to clean things up so that you have a uniform list for your pivot table so that it might properly summarize the data.

One way I see, is to have your Pivot table do this, you are going to have to go back to signing.

Have revenues brought in as Positive numbers, COGS, Depreciation, Interest and taxes brought in as negatives.

Setting your pivot table to sum these values, the Grand Total will be the NI.
Add a second column of the exact same values being summed up.

For this 2nd column, go to the Field settings, in the dialogue box that opens, go to the 2nd tab "Show Value as"
Select Show value as "% of total"

This will break everything out to their corresponding % of Net Income. The summary field for Revenues. This would get you close.

The only other option is to run a custom formula on the Right hand side of the pivot table to pick up on these fields.

=IF(A3="Total Sales",OFFSET(\$B\$1,COUNTA(\$B:\$B)-1,0)/B3,"")
OR
=IF(A3="01 - Revenues",GETPIVOTDATA("Sum of Balance",\$A\$1)/B3,"")
This is assuming that the Grouped Revenues would be called Total Sales and that your figures are in Column B where there are no extra entries. The offset formula is just there to find the end value.

Just start entering the formula and click where the NI calculates at the bottom for it to automatically insert the GETPIVOTDATA() reference for you.

Hopefully this helps,
jc

Last edited:
Thanks JC. I will give this a go and keep you posted. I really appreciated a detailed reply from you, that was nice of you.

Thanks again

Replies
1
Views
82
Replies
1
Views
367
Replies
1
Views
348
Replies
0
Views
191
Replies
1
Views
58

Threads
1,203,453
Messages
6,055,530
Members
444,794
Latest member
HSAL

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

### Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

### Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back