Roger Federer booked his spot in the last four of the ATP Finals for the 15th time in his career and claimed his opening loss to Kei Nishikori helped him to dig deep in his last two matches.

The 37-year-old overcame Kevin Anderson 6-4 6-3 to top his group, joining both the South African and Novak Djokovic in the semi-finals of the season-ending tournament in London.

Anderson and Djokovic sealed their last-four berths having won each of their first two matches, yet Federer's shock opening loss to Nishikori had left him up against it in his final two encounters.

However, having beaten Dominic Thiem on Tuesday, the Swiss was at his scintillating best on Thursday to see off Anderson, who had beaten Federer in the Wimbledon quarter-finals earlier this year.

"I'm very happy," Federer said in his on-court interview afterwards.

"The first match was tough against Kei, I never got going. With my back against the wall, maybe it is easier for me to play.

"I tried to come up with a good game plan against Dominic and also Kevin today. I'm happy it all worked out. I'm thrilled to be in the semis.

"These round-robin formats are not straightforward; you feel like you can lose a match and still go on.

"We're used to you lose, you leave, you don't hang around.

"From that standpoint, it was more straightforward for me today."

Thiem had done Federer a favour by beating Nishikori earlier in the day and the Swiss thought the group's situation impacted both him and Anderson in their contest.

"I think it was maybe different for Kevin because he knew he had qualified and Thiem winning helped me to be more relaxed," he added.

"But I always wanted to go out with a bang, win the match and if I go through, great."