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:

AS URLESCAPEFRAGMENT("[Geography].[City].&[Abingdon]&[ENG]")
FROM [Adventure Works]

It returns the following result set:
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 response

  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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: