I did check your document and your problem is not in the expression. The problem is your tables relationship. I cannot tell exactly what do you need to change because I do not know your data but you have a very complex structure and a lot of synthetic keys. I recommend to build a Star Schema. That exercise will not only resolve your problem, if you do this correctly, but also improve performance.