The secondary flow increases the loss and changes the flow incidence in the downstream blade row. To prevent hot gases from entering disk cavities, purge flows are injected into the mainstream in a real aero-engine. The interaction between purge flows and the mainstream usually induces aerodynamic losses. The endwall loss is also affected by shedding wakes and secondary flow from upstream rows. Using a series of eddy-resolving simulations, this paper aims to improve the understanding of the interaction between purge flows, incoming secondary flows along with shedding wakes, and mainstream flows on the endwall within a stator passage. It is found that for a blade with an aspect ratio of 2.2, a purge flow with a 1% leakage rate increases loss generation within the blade passage by around 10%. The incoming wakes and secondary flows increase the loss generation further by around 20%. The purge flow pushes the passage vortex further away from the endwall and increases the exit flow angle deviation. However, the maximum exit flow angle deviation is reduced after introducing incoming wakes and secondary flows. The loss generation rate is calculated using the mean flow kinetic energy equation. Two regions with high loss generation rate are identified within the blade passage: the corner region and the region where passage vortex interacts with the boundary layer on the suction surface. Loss generation rate increases dramatically after the separated boundary layer transitions. Since the endwall flow energizes the boundary layer and triggers earlier transition on the suction surface, the loss generation rate close to the endwall at the trailing edge (TE) is suppressed.