Named Calculation expressions

POSTED BY niklas on Feb 1 under Technology, Work

Just a quick note on Name Calculations in SSAS, they need to be written in whatever SQL dialect the underlying DB engine (probably MS-SQL) understands. I wanted to make a Sales Margin calculation, and to avoid a Divide by Zero where sale price was zero, my code for this was:

CASE
WHEN Sale<>0 THEN (Sale-Cost)/Sale
ELSE 0
END

Never before have I needed four lines to do a simple IF. ;-)

Leave a Comment

If you would like to make a comment, please fill out the form below.

Name (required)

Email (required)

Website

Comments

Copyright Niklas Saers, 2000-2008