# How to: use a logical \`and\` to evaluate a conditional expression in a Config template

**URL:** <https://community.replicated.com/t/how-to-use-a-logical-and-to-evaluate-a-conditional-expression-in-a-config-template/614>\
**Category:** Packaging an application\
**Tags:** kots, config, templating\
**Created:** [December 13, 2021, 3:37pm UTC](https://community.replicated.com/t/how-to-use-a-logical-and-to-evaluate-a-conditional-expression-in-a-config-template/614 "2021-12-13T15:37:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![adamancini](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.replicated.com/adamancini/32/229_2.png) [@adamancini](https://community.replicated.com/u/adamancini)\
**Post date:** [December 13, 2021, 3:37pm UTC](https://community.replicated.com/t/how-to-use-a-logical-and-to-evaluate-a-conditional-expression-in-a-config-template/614/1 "2021-12-13T15:37:31Z")

</div>

How do I display a Config option only when two or more other items are True or False? I tried

```auto
when: repl{{ ConfigOptionEquals "option_one" "0" }} & repl{{ ConfigOptionEquals "option_two" "0" }}

```

but this isn’t working as expected.

Answer:  
Only show option `foo` if both options are false.

```auto
    - name: conditional_and
      title: Conditional conditional
      description: only shows up when both option_one and option_two are set to False
      when: repl{{ (and (ConfigOptionEquals "option_one" "false") (ConfigOptionEquals "option_two" "false")) }}
      items:
        - name: foo
          title: foo
          type: text
          default: "foo"

```

---

<div class="post-metadata">

**Author:** ![Fernando\_Cremer](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.replicated.com/fernando_cremer/32/436_2.png) [@Fernando\_Cremer](https://community.replicated.com/u/Fernando_Cremer)\
**Post date:** [February 1, 2022, 4:07pm UTC](https://community.replicated.com/t/how-to-use-a-logical-and-to-evaluate-a-conditional-expression-in-a-config-template/614/2 "2022-02-01T16:07:07Z")

</div>

You can use both `and` as well as `or` in the `when` field if you are using templating.

Here is an example config that displays labels based on which options are selected:

```auto

apiVersion: kots.io/v1beta1
kind: Config
metadata:
  name: config-sample
spec:
  groups:
    - name: example_settings
      title: My Example Config
      description: Configuration to serve as an example for creating your own. See [https://kots.io/reference/v1beta1/config/](https://kots.io/reference/v1beta1/config/) for configuration docs. In this case, we provide example fields for configuring an Ingress object.
      items:
        - name: option-1
          title: option 1
          type: bool
          default: "0"
        - name: option-2
          title: option 2
          type: bool
          default: "0"
        - name: option-3
          title: option 3
          type: bool
          default: "0"  
        - name: option-1-and-2
          title: Option 1 and 2 are selected
          type: label
          when: repl{{ and (ConfigOptionEquals "option-1" "1") (ConfigOptionEquals "option-2" "1") }}
        - name: option-1-or-3
          title: Option 1 or 3 are selected
          type: label
          when: repl{{ or (ConfigOptionEquals "option-1" "1") (ConfigOptionEquals "option-3" "1") }}

```

Here is how it behaves in a deployed instance:

![ezgif.com-gif-maker](https://canada1.discourse-cdn.com/flex030/uploads/replicated/original/1X/242dc9532353a070ab234be68fe06d94bbd8ae18.gif)
