Skip to content
Advertisement

Count distinct values in ColumnA for each unique value in ColumnB

I have a table of shipment numbers (can be duplicate) and a concatenated field of their origin – destination (can be duplicate). I have a select column that selects all of the origin-destinations for each shipment number. I want to add a 3rd column that gets the number of unique origin-destinations for each unique shipment number.

I tried to do a

and also tried

instead of [OD]. Everything returns 1 in my additional column.

Desired Results:

Current Results:

I want the output for A484312 on both lines to be 2, not 1.

Desired Results:

Advertisement

Answer

I think you want a window function:

Hmmm . . . if your current counts are 1, you don’t need aggregation:

EDIT:

If think you actually want:

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement