Power Query - percentage of Yes, No, N/A responses per person

JugglerJAF

Active Member
Joined
Feb 17, 2002
Messages
297
Office Version
  1. 365
Platform
  1. Windows
I have a table of data showing calls made by people in the business, so the same name can appear multiple times as each person can make multiple calls. For each call, I have a "response" column which contains a value of either "Yes", "No", or "N/A"

What I'm trying to do (in Power Query) is to generate summary showing the total number of times each person appears (simple enough, I've used "group by" on name and done a count of rows), but I also need for each person the percentage of responses that are "Yes", "No", or "N/A" (the attached "count" image shows an interim count and "percentages" shows the expected output.

I have managed to do this in power query with some test data as shown in in the attached images, but it was very fiddly to do and I'm wondering if there's a better way of approaching this as my actual data is more complex. My solution on the example data was:
  1. Add in 3 custom columns (Yes Count, No Count and NA Count) using an IF command to replace the value being looked for in each column with 1 and everything else as zero, so in the Yes Count column, all instances of Yes were replaced with 1 and everything else replaced with zero, the No Count column replaced instances of No with 1 and everything else replaced with zero, and so on.
  2. Once I had the 3 new "count" columns, I could use them in the "group by" command to sum each column which gave me a total count of Yes, No, and N/A for each person
  3. I then added 3 more custom columns, each with a calculation of: each "count column" value divided by the total number of records for each person to give me the percentage.
It works, but it's fiddly and I'm hoping that there's an easier way, because the actual data I have to work with doesn't have 1 "response" column, it has 11, and each column has 5 potential responses, not 3, so the approach above would require adding in and calculating 110 new columns which I'd like to avoid if at all possible!
 

Attachments

  • 1 data.png
    1 data.png
    5.9 KB · Views: 11
  • 2 count.png
    2 count.png
    4.2 KB · Views: 8
  • 3 percentages.png
    3 percentages.png
    5.4 KB · Views: 11

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Forum statistics

Threads
1,215,059
Messages
6,122,918
Members
449,093
Latest member
dbomb1414

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