# Set a variable from a Data group

**URL:** <https://community.f5.com/t/set-a-variable-from-a-data-group/69877>\
**Category:** Technical Forums\
**Tags:** application-delivery\
**Created:** [June 6, 2022, 4:50pm UTC](https://community.f5.com/t/set-a-variable-from-a-data-group/69877 "2022-06-06T16:50:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mario\_Franco](https://avatars.discourse-cdn.com/v4/letter/m/e19b73/32.png) [@Mario\_Franco](https://community.f5.com/u/Mario_Franco)\
**Post date:** [June 6, 2022, 4:50pm UTC](https://community.f5.com/t/set-a-variable-from-a-data-group/69877/1 "2022-06-06T16:50:10Z")

</div>

Hi everyone,

I have an irule with a static variable “set example 1” which is used when we need to point to a specific virtual server, and we change it to “Set example 0” when we want to move the traffic to another virtual server, the thing is now we have many irules and when we want to move the traffic we need go one by one and change the variable, I am thinking of setting the variable with a data group where we just need to go there and change the value in the datagroup “1” or “0”, is it possible? or there are any other option?

---

<div class="post-metadata">

**Author:** ![Patrik\_Jonsson](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/patrik_jonsson/32/20827_2.png) [@Patrik\_Jonsson](https://community.f5.com/u/Patrik_Jonsson)\
**Post date:** [July 29, 2022, 8:30pm UTC](https://community.f5.com/t/set-a-variable-from-a-data-group/69877/2 "2022-07-29T20:30:51Z")

</div>

You probably have figured it out by now but just in case, here’s an example.

Data group list:

```tcl
ltm data-group internal /Common/select_server {
    records {
	server {
            data a
        }
    }
    type string
}

```

And the rule:

```tcl
when HTTP_REQUEST {

  # Below is the droid... I mean line you're looking for
  set selected_server [class lookup "server" select_server]
  HTTP::respond 200 content $selected_server

}

```

Good luck!

Kind regards,  
Patrik
