URL Encoding in MDX

Been a bit busy this week, so only a short entry but hopefully a useful one. Continuing my series on undocumented new features in AS2005, I present the URLESCAPEFRAGMENT function which performs url encoding on a string. Here’s an example of how it works:
 

WITH MEMBER MEASURES.TEST
AS URLESCAPEFRAGMENT("[Geography].[City].&[Abingdon]&[ENG]")
SELECT MEASURES.TEST ON 0
FROM [Adventure Works]

 
It returns the following result set:
TEST
%5bGeography%5d.%5bCity%5d.%26%5bAbingdon%5d%26%5bENG%5d
 
Why on earth do you want to do this though? Well I came across a problem last year when I was creating actions that created dynamic urls. I wanted to embed a unique name inside my url and realised that all those square brackets and ampersands needed to be replaced with escape characters, and couldn’t find an easy way of doing this (the only option seemed to be to do some custom coding). However the guys on the dev team were way ahead of me and as soon as I asked about this problem, they told me about this function.

One thought on “URL Encoding in MDX

  1. Also came across an example in the Adventure Works cube itself – the "Sales Reason Comparisons" Reporting Action has a "ProductCategory" parameter, whose value is: \’UrlEscapeFragment( [Product].[Category].CurrentMember.UniqueName )\’

Leave a Reply to DeepakCancel reply