I think this post will help you. It's not related to the Contributions cube but I used the same advanced formula and it worked well for contributions!