Calculated field with column subitems?

YounesB3

Board Regular
Joined
Mar 28, 2012
Messages
148
Hi, I have a source data which I can't change because if I add a column with a formula, it will make the file that much heavier.

I'd like to calculate a simple ratio of calculations. Here's a simulated example of what I'd like.

[TABLE="width: 500"]
<tbody>[TR]
[TD]Column A[/TD]
[TD]Column B[/TD]
[/TR]
[TR]
[TD]AB[/TD]
[TD]Yes1[/TD]
[/TR]
[TR]
[TD]AB[/TD]
[TD]No[/TD]
[/TR]
[TR]
[TD]EF[/TD]
[TD]-[/TD]
[/TR]
[TR]
[TD]CD[/TD]
[TD]-[/TD]
[/TR]
[TR]
[TD]AB[/TD]
[TD]Yes2[/TD]
[/TR]
[TR]
[TD]CD[/TD]
[TD]-[/TD]
[/TR]
[TR]
[TD]AB[/TD]
[TD]Yes3[/TD]
[/TR]
[TR]
[TD]AB[/TD]
[TD]No[/TD]
[/TR]
[TR]
[TD]AB[/TD]
[TD]Yes1[/TD]
[/TR]
</tbody>[/TABLE]


Basically, I want a calculated field of a ratio of i/j:
i =being a countifs of all the AB and Yes1, Yes2, Yes3
j = being a countif of all the AB.

It would be easy by adding a new column, but I can't. I thought that it would be possible with a calculated field in a pivot table, but I can't find the option to do what I want. Any help would be appreciated.
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Maybe this:
Code:
=SUMPRODUCT(--(A:A="AB"),--(LEFT(B:B,3)="Yes"))/COUNTIF(A:A,"AB")
 
Upvote 0
Maybe this:
Code:
=SUMPRODUCT(--(A:A="AB"),--(LEFT(B:B,3)="Yes"))/COUNTIF(A:A,"AB")

Hi the "Yes" were examples. It's actually 3 different labels.

Also, this would be the pivot calculated field? You can have ranges in the calculated field?
 
Upvote 0
Just do each individual label and add them up:
Code:
=(COUNTIFS(A:A,"AB",B:B,"Yes1")+COUNTIFS(A:A,"AB",B:B,"Yes2")+COUNTIFS(A:A,"AB",B:B,"Yes3"))/COUNTIF(A:A,"AB")
You can replace the entire column references with specific range references, i.e. change A:A to A1:A100, if you like.

I don't really work with pivot calculated fields, so really cannot answer that question for you.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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

Which adblocker are you using?

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
Back
Top