A method for determining an undesired condition in an electrical drive system comprising an electrical machine and an electrical drive , wherein the undesired condition is a failure condition or a condition which in time potentially may lead up to a failure condition, wherein the method comprises: a) obtaining a measured signal of an electrical or mechanical parameter concerning the electrical drive system , wherein the electrical or mechanical parameter is either a pure electrical parameter such as current, or a pure mechanical parameter such as mechanical rotation speed of a rotor, b) obtaining a frequency spectrum of the measured signal by means of the Fast Fourier Transform, which frequency spectrum contains a measured frequency component, c) determining whether a point in the plane having as its coordinates a value of the measured frequency component and the fundamental frequency of the measured signal, is within a predetermined distance from a trend line (T2, T3, T5, T6, T9), which trend line is associated with only one specific harmonic of the electrical or mechanical parameter present during a specific undesired condition, and utilising the Mahalanobis distance to determine a distance between the point and the trend line (T2, T3, T5, T6, T9) to determine whether the point is within the predetermined distance from the trend line, d) on the condition that the point is within the predetermined distance from the trend line, increasing a counter associated with the trend line (T2, T3, T5, T6, T9), e) repeating steps a) to d), wherein in case the counter reaches a predetermined number within a predetermined number of iterations of steps a) to d), f) determining based on that the counter reaches the predetermined number that the harmonic associated with the trend line is present in the measured signal and thereby that the electrical drive system is subjected to the undesired condition associated with the trend line (T2, T3, T5, T6, T9). a) obtaining a measured signal of an electrical or mechanical parameter concerning the electrical drive system , wherein the electrical or mechanical parameter is either a pure electrical parameter such as current, or a pure mechanical parameter such as mechanical rotation speed of a rotor, b) obtaining a frequency spectrum of the measured signal by means of the Fast Fourier Transform, which frequency spectrum contains a measured frequency component, c) determining whether a point in the plane having as its coordinates a value of the measured frequency component and the fundamental frequency of the measured signal, is within a predetermined distance from a trend line (T2, T3, T5, T6, T9), which trend line is associated with only one specific harmonic of the electrical or mechanical parameter present during a specific undesired condition, and utilising the Mahalanobis distance to determine a distance between the point and the trend line (T2, T3, T5, T6, T9) to determine whether the point is within the predetermined distance from the trend line, d) on the condition that the point is within the predetermined distance from the trend line, increasing a counter associated with the trend line (T2, T3, T5, T6, T9), e) repeating steps a) to d), wherein in case the counter reaches a predetermined number within a predetermined number of iterations of steps a) to d), f) determining based on that the counter reaches the predetermined number that the harmonic associated with the trend line is present in the measured signal and thereby that the electrical drive system is subjected to the undesired condition associated with the trend line (T2, T3, T5, T6, T9). <EOS>