Selected Answer
If I understand your requirement correctly, your current formula in column J should do the job.
=COUNTIFS($B:$B,$B2,$G:$G,$G2)
Its essential difference from the formula in column K [=COUNTIF($G$2:G2,G2)] is in the definition of the count range. $G$2:G2 counts within a range starting from G2 and ending in the row where the formula resides, excluding anything below that row. $G:$G on the other hand counts everything in the column. The COUNTIFS() function above will return 2 for both, rows 27 and 28.
=COUNTIFS($B:$B,$B2,$G:$G,$G2)-1
would return the number of duplicates, meaning it returns 0 if there is only one occurrence. You might then suppress the display of zero in some way so that items which have no duplicates show a blank cell.
One method to suppress the display of zeroes is to set Advanced Options for the worksheet. This will affect all zeroes in the sheet. If that is too broad, perhaps because you need to show zeroes in another column, you can use a cell format like 0;0;; only for the cells in which you want to suppress the display.