Chris Webb's BI Blog

Analysis Services, MDX, PowerPivot, DAX and anything BI-related

URL Encoding in MDX

with one comment

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.

Written by Chris Webb

February 3, 2006 at 10:32 am

Posted in MDX

One Response

Subscribe to comments with RSS.

  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 )\’

    Deepak

    February 4, 2006 at 4:39 am


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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 3,081 other followers

%d bloggers like this: