This paper extends Kreins spectral shift function theory to the setting of semifinite spectral triples. We define the spectral shift function under these hypotheses via Birman-Solomyak spectral averaging formula and show that it computes spectral flow.