Hello again,
maybe someone of you ran into a similar problem and might have a hint for me.
I'm struggling at the moment with a field transform.
The groovy function there is supposed do the following
Check if KPI (_input1) is Price -> then return value (_input2)
check if KPI is amount -> then check if value = PlanSource then return PlanTarget [PlanSource and PlanTarget are both variables), else check value
example:
$PlanSource = 2416.0
$PlanTarget = 600.0
This should result in:
I tried it with an if-statement as well as switch. Unfortunately both don't work. Somehow the function cannot assert the input with the variable Value. If I type in a value instead of the variable PlanSource, the snippet works.
Both work in groovy webconsole: groovyconsole.appspot.com/
Display All
Display All
Does anybody have an idea?
Thanks in advance.
Bjoern
maybe someone of you ran into a similar problem and might have a hint for me.
I'm struggling at the moment with a field transform.
The groovy function there is supposed do the following
Check if KPI (_input1) is Price -> then return value (_input2)
check if KPI is amount -> then check if value = PlanSource then return PlanTarget [PlanSource and PlanTarget are both variables), else check value
example:
#1 | Price | 150.0 |
#2 | Amount | 1000.0 |
#3 | Amount | 2416.0 |
$PlanSource = 2416.0
$PlanTarget = 600.0
This should result in:
#1 | Price | 150.0 |
#2 | Amount | 1000.0 |
#3 | Amount | 600.0 |
I tried it with an if-statement as well as switch. Unfortunately both don't work. Somehow the function cannot assert the input with the variable Value. If I type in a value instead of the variable PlanSource, the snippet works.
Both work in groovy webconsole: groovyconsole.appspot.com/
Java Source Code
- PlanSource = ${HPPlanSource}
- PlanTarget = ${HPPlanTarget}
- //KPI = Price -> Value
- if (_input1 == "Price") {
- return _input2;
- }
- // KPI = Amount
- // Amount = Plan of source -> Plan of Target Project
- else if (_input2 == PlanSource) {
- return PlanSource;
- }
- // Menge <> Plan -> Amount of SourceTable
- else {
- return _input2;
- }
Java Source Code
- HPPlanSource = ${HPPlanSource}
- HPPlanTarget = ${HPPlanTarget}
- switch(_input1) {
- // if KPI = Preis return input2 (Preis value)
- // if KPI = Menge
- // if input2(value) = HPPlanSource return HPPlanTarget
- // else input2 (Menge value)
- case "Preis":
- return _input2;
- break;
- case "Menge":
- switch(_input2){
- case HPPlanSource:
- return HPPlanTarget;
- break;
- default:
- return _input2;
- }
- default:
- return _input2;
- }
Thanks in advance.
Bjoern