This tense is also called Past Perfect Progressive.
It is simple to form; easy to confuse!
Here are a few example sentences
"She had been working here for over 2 years before you started working here."
"I was exhausted because I had been staying awake too late."
"They had not been waiting for more than 30 minutes when the bus picked them up."
Form: The Past Perfect Continuous is had been + present continuous (-ing)
It is used for past actions that were unfinished when another action happened: "I had been studying at university for 6 months before I met her." - studying at university = past unfinished action; I met her (second action happened / interrupted the first action).
The Past Perfect Continuous shows us that something started in the past and continued up until another time in the past. You can use time expressions like 'for' and 'since' with this tense: "They had been sleeping for an hour before I went to bed."
If you do not want to show a length of time, use the past continuous instead: "They were sleeping before I went to sleep."
Use it when you want to show cause and effect: "I put on weight because I had been eating too much."
Now complete these sentences using the Past Perfect Continuous: