Assuming there is always a Line Item 1 on each invoice, you can use:
Formula: copy to clipboard
=COUNTIFS(Sample2!$B$2:$B$14,1,Sample2!$C$2:$C$14,Sample1!A2)