billchen198318 / bamboobsc

next version move to https://github.com/billchen198318/hillfog, bambooBSC is an opensource Balanced Scorecard (BSC) Business Intelligence (BI) Web platform. BSC's Vision, Perspectives, Objectives of strategy, Key Performance Indicators (KPIs), Strategy Map, and SWOT, PDCA & PDCA report, Time Series Analysis.
Apache License 2.0
227 stars 109 forks source link

Fix Personal / Department report score always zero #22

Closed billchen198318 closed 8 years ago

billchen198318 commented 8 years ago

Personal / Department report score always zero, but the measure-data has been entered! There are two ways to solve:

A recommended use solution-1, it is easy than solution-2.

only for 'F001 percent of target' formula

Click 03 - Formula s-001

Edit F001 percent of target s-002

Solution 1. Change expression type change type as java(BeanShell2) and click Save button before expression content no need modify. 0001


Solution 2. If expression type use GROOVY, need modify expression-content. and click Save button


import org.apache.commons.lang3.math.*;
import java.lang.*;

if (actual > 0 && target > 0 ) {
    ans = Math.max( actual ÷ target ,  0 ) × 100;
    ans = NumberUtils.toFloat( String.valueOf(ans), 0.0f);
    return ans;
}
if (
    (actual <= 0 && target < 0 && actual >= target)
    ||
    (actual <= 0 && target < 0 && actual < target)
    ||
    (actual > 0 && target < 0 )
) {
    ans = ((((target - actual) ÷ target) × 100) + 100);
    ans = NumberUtils.toFloat( String.valueOf(ans), 0.0f);
    return ans;
}
if (actual < 0 && target > 0 ) {
    ans = ((((actual - target) ÷ target) × 100) + 100);
    ans = NumberUtils.toFloat( String.valueOf(ans), 0.0f);
    return ans;
}
if (actual == 0 && target > 0 ) {
    ans = 0;
    ans = NumberUtils.toFloat( String.valueOf(ans), 0.0f);
    return ans;
}
if (actual >= 0 && target == 0 ) {
    ans = ((actual × 100) + 100);
    ans = NumberUtils.toFloat( String.valueOf(ans), 0.0f);
    return ans;
}
if (actual < 0 && target == 0 ) {
    ans = ((actual × 100) + 100);
    ans = NumberUtils.toFloat( String.valueOf(ans), 0.0f);
    return ans;
}
ans = 0;
ans = NumberUtils.toFloat( String.valueOf(ans), 0.0f);
return ans;

Test report result s-003