Raising your own errors in Yukon

Another thing I’ve noticed in Books Online – the new ERROR function, which allows you to raise your own errors. For example in AdventureWorks, try the following query:

WITH MEMBER MEASURES.TEST AS
IIF(MEASURES.[INTERNET ORDER COUNT]>2000
, MEASURES.[INTERNET ORDER COUNT]
, ERROR("TOO LOW!")
)
SELECT {MEASURES.[INTERNET ORDER COUNT], MEASURES.TEST} ON 0,
[DATE].[CALENDAR TIME].[ALL PERIODS].CHILDREN ON 1
FROM
[DIRECT SALES]

There’s a section in BOL on error handling which isn’t filled in yet so I guess this is probably only the tip of the iceberg as far as this area of functionality is concerned, but it’s interesting nonetheless.

One response

  1. It isn\’t a tip of the iceberg – it is the entire iceberg in this area. I.e. you can put an MDX expression which returns a string inside Error function:Error("Product " + Product.CurrentMember.UniqueName + " has encountered an error in member property Weight")

Leave a Reply

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

%d bloggers like this: