• Apologies for the shameless plug, but have a look at the following blog post which will describe your issue and how to test potential solutions:

    http://did-i-say-that.com/2015/04/16/mdx-testing-with-settostr-function/