Count equal values in one column, different rows.

maxiwoll

New Member
Joined
Apr 27, 2015
Messages
3
Hi! I have been trying to count duplicate BOMHeader for a while by using DCount and variations of Count, but with no luck.
The result I want is laid out in the table below.. But I cannot manage to count duplicate values and show the count in a new coloumn.

The reason for asking is that I have a database with spare parts, and the top level is called BOMHeader, with a list of items connected to the BOMheader in a separate table. I manage to count all items connected to the BOMheader, but I cannot count the number of times a BOM header is connected to a functional location ID. As you see the BOMHeader 329002 is connected to 2 functional location IDs, I have a list of 1500 functional locations...

DCount(expression;domain;[criteria]), is this at all possible?

Functional location IDBOMHeaderCountOfBOMHeader
540-289-EC-00013290022
540-289-EC-00023290022
540-289-EC-00033290133
540-289-EC-00043290133
540-289-EC-00053290133

<tbody>
</tbody>


Thank you for all help.
 

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.
Additional information regarding the tables.

The relationship of the tables are: Functional location table(Functional location id, equipentnumber) is connected to an equipmentt table (Equipment number, bom material), connected to BOM detail table (BomHeader, Bomdetail), which again is connected to a table with all item details (item number, description etc)
 
Upvote 0
Create a Total Query by combining both 'Functional Location ID' and 'BOMHeader' fields like the sample SQL given below:

Code:
SELECT [Functional Location ID], [BomHeader], Count([BomHeader]) As myCount
FROM TableName
GROUP BY [Functional Location ID], [BomHeader];

If first two fields are in different tables then combine them together in a SELECT Query first by linking both the information through a common field in both tables. Use the Select Query as source for the Total Query.
 
Upvote 0
Tried your code, but the result was a column myCount with "1" in all rows.
The fields are in two different tables, but I do not understand how to combine them in a Total Query. Can you please explain? :)
 
Upvote 0
Copy Paste the following SQL into a new Query's SQL editing window, make changes whereever Table Name or Field Name is in error and save the query with the name Query1:

Code:
SELECT [Functional location].[Functional Location ID], [BOM detail].[BOMHeader]
FROM [BOM detail]
INNER JOIN [Functional Location] ON [Equipment].[Equipmentnumkber]
INNER JOIN [BOM detail] ON [Equipment].[bom material]=[BOM detail].[BOMHeader];

Use Query1 as source Data Set for the Count taking Total Query as shown below:

Code:
SELECT Query1.[BOMHeader], Count(Query1.[Functional Location ID]) as myCount
FROM Query1
GROUP BY Query1.[BOMHeader];
 
Upvote 0

Forum statistics

Threads
1,221,876
Messages
6,162,567
Members
451,775
Latest member
Aiden Jenner

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