Archive for February, 2007

Lose those single quotes!

Monday, February 12th, 2007

Although they're no longer necessary in AS2005 MDX and I no longer bother with them, I've seen a lot of examples of people still using single quotes in MDX in calculated member and set definitions. Up until recently I thought this was just a matter of taste and that it did no harm to leave them in, but last week I realised that if you do leave them in it makes debugging MDX queries much harder. To illustrate, run the following two MDX queries:

WITH MEMBER MEASURES.TEST AS BLAH
SELECT
{[Measures].TEST}
ON COLUMNS
FROM [Adventure Works]

and

WITH MEMBER MEASURES.TEST AS 'BLAH'
SELECT
{[Measures].TEST}
ON COLUMNS
FROM [Adventure Works]

Both return errors. The first gives this error message the single cell returned:
VALUE #Error Query (1, 30) The dimension '[BLAH]' was not found in the cube when the string, [BLAH], was parsed.

but the second gives this error message in the same place:
VALUE #Error The dimension '[BLAH]' was not found in the cube when the string, [BLAH], was parsed.

So you can see if you don't use single quotes and there's an error somewhere in your calculated member definitions you get the row and column where the error was found (highlighted in bold); if you do use single quotes you don't get this useful information. For some of the three or four page queries that I sometimes have to debug this can save a lot of time...

Lose those single quotes!

Monday, February 12th, 2007

Although they're no longer necessary in AS2005 MDX and I no longer bother with them, I've seen a lot of examples of people still using single quotes in MDX in calculated member and set definitions. Up until recently I thought this was just a matter of taste and that it did no harm to leave them in, but last week I realised that if you do leave them in it makes debugging MDX queries much harder. To illustrate, run the following two MDX queries:

WITH MEMBER MEASURES.TEST AS BLAH
SELECT
{[Measures].TEST}
ON COLUMNS
FROM [Adventure Works]

and

WITH MEMBER MEASURES.TEST AS 'BLAH'
SELECT
{[Measures].TEST}
ON COLUMNS
FROM [Adventure Works]

Both return errors. The first gives this error message the single cell returned:
VALUE #Error Query (1, 30) The dimension '[BLAH]' was not found in the cube when the string, [BLAH], was parsed.

but the second gives this error message in the same place:
VALUE #Error The dimension '[BLAH]' was not found in the cube when the string, [BLAH], was parsed.

So you can see if you don't use single quotes and there's an error somewhere in your calculated member definitions you get the row and column where the error was found (highlighted in bold); if you do use single quotes you don't get this useful information. For some of the three or four page queries that I sometimes have to debug this can save a lot of time...

Committing Writeback Transactions in MDX

Friday, February 9th, 2007
Today I answered a question on the MSDN Forum about writeback by saying that it was only possible to commit a writeback transaction using code. Turns out I was wrong:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1211688&SiteID=1&mode=1
 
If you execute a BEGIN TRAN statement in MDX before you do your UPDATE CUBE then execute a COMMIT TRAN statement, then the writeback changes get committed to the cube; alternatively you can execute a ROLLBACK statement and any changes you made with UPDATE CUBE are lost. This works for AS2K as well as AS2005.

Committing Writeback Transactions in MDX

Friday, February 9th, 2007
Today I answered a question on the MSDN Forum about writeback by saying that it was only possible to commit a writeback transaction using code. Turns out I was wrong:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1211688&SiteID=1&mode=1
 
If you execute a BEGIN TRAN statement in MDX before you do your UPDATE CUBE then execute a COMMIT TRAN statement, then the writeback changes get committed to the cube; alternatively you can execute a ROLLBACK statement and any changes you made with UPDATE CUBE are lost. This works for AS2K as well as AS2005.

Custom List: Popular Entries

Thursday, February 8th, 2007

Popular Entries

Crossjoin function now takes more than two parameters

Friday, February 2nd, 2007
Crossjoin is a function which, for obvious reasons, is dear to my heart. It's been at least a year since I last found a feature in AS2005 MDX that I wasn't aware of, but the other day I found out that the Crossjoin function can now take more than two sets as parameters, much in the same way that NonEmptyCrossjoin can. Here's an example:
 
select
measures.[internet sales amount] on 0,
crossjoin(
[Date].[Day Name].[Day Name].members,
[Date].[Day of Week].[Day of Week].members,
[Product].[Color].[Color].members
)
on 1
from [Adventure Works]
 
Not exactly revolutionary (and anyway I use the * operator instead nowadays) but fun to note.

Crossjoin function now takes more than two parameters

Friday, February 2nd, 2007
Crossjoin is a function which, for obvious reasons, is dear to my heart. It's been at least a year since I last found a feature in AS2005 MDX that I wasn't aware of, but the other day I found out that the Crossjoin function can now take more than two sets as parameters, much in the same way that NonEmptyCrossjoin can. Here's an example:
 
select
measures.[internet sales amount] on 0,
crossjoin(
[Date].[Day Name].[Day Name].members,
[Date].[Day of Week].[Day of Week].members,
[Product].[Color].[Color].members
)
on 1
from [Adventure Works]
 
Not exactly revolutionary (and anyway I use the * operator instead nowadays) but fun to note.