top of page
Search

Different rounding methods in SQL Server relational engine and SSAS

  • Writer: Kennie Nybo Pontoppidan
    Kennie Nybo Pontoppidan
  • Dec 21, 2014
  • 1 min read

My super cool colleague Dan told me, that apparently the rounding methods implemented in the SQL Server engine and in SSAS MDX are different. Gotcha!

Let's try to round the values -25.5, -24.5, 24.5, and 25.5 to 0 (zero) decimals in the different engines.

In MDX, we get -26, -24, 24, 26:


Rounding in SSAS

In T-SQL, we get -25, -24, 24, 25:


Rounding in T-SQL

Oh, and in SSAS tabular DAX, you just specify your rounding behaviour, using functions ROUNDUP or ROUNDDOWN

Read more about

Rounding problem in SSAS MDX here

DAX rounding here

Wikipedia (as always) have more information on rounding that you would wish for your worst enemy to read here:

T-SQL script:

use tempdb go

select Round(23.5, 0) as [Round(23.5, 0)] , Round(24.5, 0) as [Round(24.5, 0)] , Round(-23.5, 0) as [Round(-23.5, 0)] , Round(-24.5, 0) as [Round(-24.5, 0)]

MDX script:

WITH MEMBER MEASURES.Round24_5 as Round(24.5,0) MEMBER MEASURES.Round25_5 as Round(25.5,0) MEMBER MEASURES.RoundMinus24_5 as Round(-24.5,0) MEMBER MEASURES.RoundMinus25_5 as Round(-25.5,0) SELECT { MEASURES.Round24_5 , MEASURES.Round25_5 , MEASURES.RoundMinus24_5 , MEASURES.RoundMinus25_5} ON COLUMNS FROM [<cube name>]

 
 
 

Comentários


© 2015 by Kennie Nybo Pontoppidan

bottom of page