Read about how to make the past perfect here.
1: Something that started in the past and continued up to another action or time in the past. The past perfect continuous tells us 'how long', just like the present perfect continuous, but this time the action continues up to a point in the past rather than the present. Usually we use 'for + time'. (We can also use the past perfect simple here, often with stative verbs.)
- She had been working at that company for a year when she met James.
- I'd been walking for hours when I finally found the house.
- We'd been living in Berlin for three months when we had to leave.
- The pavement was wet, it had been raining. (The rain had finished before the time I'm describing in the past. We could see the result of the rain.)
- The children had been playing and so the room was a mess!
- I'd been working before I saw you and that's why I was really tired.
Try some other exercises about the past perfect continuous here.