# Expression to access an address -Siemens-

**URL:** <https://forum.inductiveautomation.com/t/expression-to-access-an-address-siemens/54445>\
**Category:** Ignition\
**Created:** [December 24, 2021, 5:43am UTC](https://forum.inductiveautomation.com/t/expression-to-access-an-address-siemens/54445 "2021-12-24T05:43:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maria\_P](https://avatars.discourse-cdn.com/v4/letter/m/838e76/32.png) [@Maria\_P](https://forum.inductiveautomation.com/u/Maria_P)\
**Post date:** [December 24, 2021, 5:43am UTC](https://forum.inductiveautomation.com/t/expression-to-access-an-address-siemens/54445/1 "2021-12-24T05:43:05Z")

</div>

Hi all,  
I’m trying to access a _dynamic_ address from a 1500 Siemens PLC. It should be something like  
[PLCName]DB50,Real300\*(2+n). Where n is a variable that actually comes from another tag. So:  
[PLCName]DB50,Real(300\*(2+{Tagxx})).

But I can’t get it working. Which type of tag should it be? An OPC Tag or an Expression tag? Can I access an address this way?  
I’ve seen the Indirect Tag binding, but I’m not sure if this fits for that case.

PD: the type of data located in this address is a real. Which Data Type for the Tag should I select? A float or a Double?

Thanks a lot!

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 24, 2021, 2:20pm UTC](https://forum.inductiveautomation.com/t/expression-to-access-an-address-siemens/54445/2 "2021-12-24T14:20:15Z")

</div>

No, you cannot make an OPC Item Path depend on another tag like this. If it doesn’t change often, you can use a change script on the other tag to rewrite the OPC Item Path on the desired tag, but note that the tag restarts, with a noticeable delay.

Typically, users would create tags for all of the values and just pick the _ **tag** _ dynamically.

---

<div class="post-metadata">

**Author:** ![Maria\_P](https://avatars.discourse-cdn.com/v4/letter/m/838e76/32.png) [@Maria\_P](https://forum.inductiveautomation.com/u/Maria_P)\
**Post date:** [December 27, 2021, 7:48am UTC](https://forum.inductiveautomation.com/t/expression-to-access-an-address-siemens/54445/3 "2021-12-27T07:48:29Z")

</div>

Thanks Pturmel!  
Creating a tag for all the values it’s not the best approach, I think, because the auxiliary value can take up to 50 different values.  
I’m trying to make a script to rewrite the OPC Item Path. I believe I can handle the delay.  
But I’m not sure about how to do it, I haven’t used any Tag script yet. On value change event, I’ve tried:  
[.]_Tag\_Name_.tagPath = tag(‘ns=1;s=[_PLC\_Name_]DB50,D’,currentValue)  
where currentValue=300\*(2+{Tagxx})  
or it works just doing: [.]_Tag\_Name_.tagPath = concat(‘ns=1;s=[_PLC\_Name_]DB50,D’,currentValue) ?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 27, 2021, 1:49pm UTC](https://forum.inductiveautomation.com/t/expression-to-access-an-address-siemens/54445/4 "2021-12-27T13:49:04Z")

</div>

You are mixing expression language with python. `tag()` and `concat()` are only usable in the expression language.

Assuming the reference tag and the dynamic tag are in the same folder, the reference tag’s value change event would look something like this:

```auto
system.tag.writeBlocking(['[.]dynamicTagName.OPCItemPath'], ['[PLC_Name]DB50,D%d' % currentValue.value])

```

---

<div class="post-metadata">

**Author:** ![Maria\_P](https://avatars.discourse-cdn.com/v4/letter/m/838e76/32.png) [@Maria\_P](https://forum.inductiveautomation.com/u/Maria_P)\
**Post date:** [January 11, 2022, 1:02pm UTC](https://forum.inductiveautomation.com/t/expression-to-access-an-address-siemens/54445/5 "2022-01-11T13:02:18Z")

</div>

Thanks @pturmel! This solved the problem.
