Friday, March 1, 2013

OBIEE 11g - Calculated % always shows up as 0%


While upgrading some of my dashboards from OBIEE 10.1.3.4 to 11.1.1.5, I noticed that some of my calculations
 in Answers were showing zeros instead of the calculated amount.  The calculation I was trying to perform was to 
calculate a match rate % for some data based on a field that showed 'MATCH' or 'NO MATCH'.  The original calculation was

(SUM(CASE BuyPoint.Match WHEN 'MATCH' THEN 1 ELSE 0 END)/COUNT(BuyPoint.Match ))*100

However, this was returning 0% as the result.  This happens when you have an integer in a calculation.  A very easy
 fix to this is to multiply by 1.0 (don't use 1, as this will not work.  Use 1.0).  The updated calculation below works and
 provides a meaningful result.

((1.0*SUM(CASE BuyPoint.Match WHEN 'MATCH' THEN 1 ELSE 0 END))/(1.0*COUNT(BuyPoint.Match )))*100