Thanks for the suggestion it worked . Below is the modified script .
A = FOREACH (COGROUP OUTER) group as url , (1-$d)+$d*(SUM(a.values) IS NULL ? 0.0 : SUM(a.values)) as totalValue How can I change it so that SUM function can be avoided twice . I am new to the PIG scripting and so I couldn't come up with better ways .