Several authors have proved Lefschetz type formulas for the local Euler obstruction. In particular, a result of this type has been proved that turns out to be equivalent to saying that the local Euler obstruction, as a constructible function, satisfies the local Euler condition (in bivariant theory) with respect to general linear forms. The purpose of the paper is to determine what prevents the local Euler obstruction from satisfying the local Euler condition with respect to functions which are singular at the considered point. This is measured by an invariant (or ‘defect’) of such functions. An interpretation of this defect is given in terms of vanishing cycles, which allows it to be calculated algebraically. When the function has an isolated singularity, the invariant can be defined geometrically, via obstruction theory. This invariant unifies the usual concepts of the Milnor number of a function and the local Euler obstruction of an analytic set.