Topic
• 2 replies
• Latest Post - ‏2013-12-17T17:12:20Z by JDD23
JDD23
8 Posts

# Pinned topic Brain Teaser - Field Comparison Script

‏2013-12-16T13:55:45Z | comparison field

I have four fields:   Cost,  SchedulePerformance, O verall Status

Each field has four possible values:  (1) Complete,  (2) Major Issues,  (3) Minor Issues, and (4) On Track.

Field value priority, from highest to lowest is:  (2) Major Issues,  (3) Minor Issues,  (4) On Track, and  (1) Complete.

I need a BASIC script that will compare the values in the Cost, Schedule, and Performance fields and place the highest prioity value contanied in the three fields in the Overall Status field.

For example, if the Cost field had a value of (2) Major Issues and the Schedule and Performance fields both had (4) On Track values, the the Overall Status field would reflect (2) Major Issues.

Any help would be much appreciated.

JDD23

• DonaldN
287 Posts

#### Re: Brain Teaser - Field Comparison Script

‏2013-12-16T23:48:12Z

Seriously, you just write your own max() function! Since you only have three values to compare, you don't even need to think about some "elegant" solution. Below psudo code should work for you.

max() {

if (cost = major or schedule = major or performance = major) {

return major

} else if (cost = minor or schedule = minor or performance = minor) {

return minor

} else if (cost = ontrack or schedule = ontrack or performance = ontrack) {

return ontrack

} esle {

return complete

}

}

• DonaldN
287 Posts

#### Re: Brain Teaser - Field Comparison Script

‏2013-12-16T23:48:12Z

Seriously, you just write your own max() function! Since you only have three values to compare, you don't even need to think about some "elegant" solution. Below psudo code should work for you.

max() {

if (cost = major or schedule = major or performance = major) {

return major

} else if (cost = minor or schedule = minor or performance = minor) {

return minor

} else if (cost = ontrack or schedule = ontrack or performance = ontrack) {

return ontrack

} esle {

return complete

}

}

• JDD23
8 Posts

#### Re: Brain Teaser - Field Comparison Script

‏2013-12-17T17:12:20Z

Thanks DonaldN, appreciate the response--not much of a brain teaser for you!

Here's the final script with orginal values converted to colors:

Dim cost
Dim schedule
Dim performance

if cost = "Red" or schedule = "Red" or performance = "Red" then
else if cost = "Amber" or schedule = "Amber" or performance = "Amber" then
else if cost = "Green" or schedule = "Green" or performance = "Green" then