Power Query - Count of items by column header

Trioptre

New Member
Joined
Aug 10, 2021
Messages
1
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hello -

I've spent hours and hours on this, but no luck. Can anyone help?

Issue: I have two tables; one source data and one lookup data. I need to count the number of times the lookup data appears in the corresponding column on the main table. The column names could be anything, but they always have a counterpart in the other table.

In the attached example, There are four columns (Month/Shape/Animal/Mineral) in the first table, and the same columns in the lookup table. The lookup table contains items that do not belong in the respective columns (i.e. "Triangle" is not a month, and "Kitten" is not a shape).

I'm trying to use Power Query to count the number of invalid entries in each column. I'm thinking that "Group By" is the way to go, but I'm still stuck....

Input Data
-Month- -Shape- -Animal- -Mineral-
January Square Puppy Gold
February Circle Kitten Quartz
Square Triangle October Amber
Circle Kitten October Lead
Square Puppy Horse Gold
Circle Puppy Goldfish Silver
May Hexagon Pig Gold


Invalid Values
-Month- -Shape- -Animal- -Mineral-
Square Kitten July Kitten
Circle Puppy October Puppy
Triangle Pig January Pig


Trying to end-up with this table:
Field Invalid Entry Count
-Month- 4
-Shape- 3
-Animal- 2
-Mineral- 0

I have also attached link to my sample workbook as well as a screenshot illustrating my issue. Any help/guidance/assistance would be ~greatly~ appreciated.


Thank you!
 

Attachments

  • Example_-_Invalid_Data_Count.jpg
    Example_-_Invalid_Data_Count.jpg
    226.1 KB · Views: 34

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Your Merge1 query might look like the one below
Power Query:
let
    Source = Table.NestedJoin(Invalid_by_Field, {"Attribute", "Value"}, Raw_Data, {"Attribute", "Value"}, "Raw_Data", JoinKind.LeftOuter),
    Transform = Table.TransformColumns(Source, {{"Raw_Data", Table.RowCount}}),
    #"Grouped Rows" = Table.Group(Transform, {"Attribute"}, {{"Sum", each List.Sum([Raw_Data]), type number}})
in
    #"Grouped Rows"
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,316
Members
452,634
Latest member
cpostell

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