4 Replies Latest reply on Apr 7, 2014 4:57 AM by MartinBridges

# Calculations based on a checkbox field

Morning

Can one do a calculation based on values in a checkbox field? It needs to be a checkbox as one or more or all values are possible. My checkbox has values 'one', 'two', 'three'.

Based upon what's selected I want to go to different layouts. I also want 'three' to take precedence over 'two', which takes precedence over 'one'.

I notice if more than one box is checked then I get a Variable value with a '¶' between them.

I also notice that the value changes ie "one¶two' or 'two¶one' depending upon which one is checked first.

The permutations are getting huge.

Is there a simple way to say...

If \$Checkbox has a 'three' in it anywhere

go to layout A

else if \$Checkbox has a 'two' in it anywhere

go to layout B

else

go to layout C

end if

regards

Martin

• ###### 1. Re: Calculations based on a checkbox field

MartinBridges wrote:

The permutations are getting huge.

Maybe, but you don't care about those permutations anyway – you just want to check for the presence of a value in a certain order:

Let [ \$checkbox ; YourTable::yourCheckboxField ]

If [ isempty ( \$checkbox ]

Exit Script

End if

Set Variable [ \$layoutName ;

Case (

not isempty ( FilterValues ( \$checkbox ; 3 ) ) ; layoutnameA ;

not isempty ( FilterValues ( \$checkbox ; 2 ) ) ; layoutnameB ;

layoutnameC )

) ]

Go to Layout [ by name ; \$layoutName )

• ###### 2. Re: Calculations based on a checkbox field

Use the Go to Layout script step. Modify it with “go to layout by name” or “go to layout by number” and provide a calculation.

go to layout Name by calculation [

Case (

patternCount( field, “three”) ; layoutA;

patternCount( field, “two”) ; layoutB ;

layoutC

]

Malcolm

• ###### 3. Re: Calculations based on a checkbox field

It would be more robust to use a script with:

If(patternCount( field, “three”))

Goto Layout[layoutA]

Else If(patternCount( field, “two”))

Goto Layout[layoutB]

Else

Goto Layout[layoutC]

End If

As any changes to layout name will not break your code.

• ###### 4. Re: Calculations based on a checkbox field

Thanks All

I was sure someone could see the simple solution. Shame I couldn't.