The past perfect continuous tense expresses two continuous actions in the past where one happens before the other (before now). Words that show duration like for, since and when are used. Look at the examples below:

Past Perfect Continuous timeline

Past Perfect Continuous timeline

One action before another in the past

  1. You had been working in that company for a decade (Action 1) before you left. (Action 2)
  2. When my husband came home, (Action 2) I had been cleaning the house the whole day. (Action 1)

In Example #1, you can clearly see two separate actions. Action (1) – working. Action (2) – you left
In Example #2, it’s the reverse. Action (1) – cleaning. Action (2) – exhausted

That means, the first / earlier action (Action 1) must contain the “had been and - ing forms. The second / later action (Action 2) contains verb in the simple past form.