# Assign a value from a data set query tag

**URL:** <https://forum.inductiveautomation.com/t/assign-a-value-from-a-data-set-query-tag/65209>\
**Category:** Ignition\
**Tags:** database, ignition79, scripting\
**Created:** [October 13, 2022, 8:42pm UTC](https://forum.inductiveautomation.com/t/assign-a-value-from-a-data-set-query-tag/65209 "2022-10-13T20:42:18Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![SOPerator](https://avatars.discourse-cdn.com/v4/letter/s/838e76/32.png) [@SOPerator](https://forum.inductiveautomation.com/u/SOPerator)\
**Post date:** [October 13, 2022, 8:42pm UTC](https://forum.inductiveautomation.com/t/assign-a-value-from-a-data-set-query-tag/65209/1 "2022-10-13T20:42:18Z")

</div>

I'm trying to grab a value from a data set type query tag, but since it makes use of brackets to grab the row and column e.g. [0, 10], I'm getting a tag path is malformed error, I saw that someone else asked a similar question and the only response was to make use of the lookup expression, which won't work for me as I don't have a way of knowing what the data I'm looking for will look like, just that it will be in x row and y column. Any help would be appreciated!

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [October 14, 2022, 1:57am UTC](https://forum.inductiveautomation.com/t/assign-a-value-from-a-data-set-query-tag/65209/2 "2022-10-14T01:57:44Z")

</div>

Are you scripting this or using an expression? What does your code look like?

If the address is not out of bounds, you should be getting a value if your script looks like this:

```auto
value = system.tag.read("[default]DatasetQueryTag").value.getValueAt(0, 10)
print value

```

If you are using an expression, then--provided the data point exists--you should you get a value if your expression looks like this:  
`{[default]DatasetQueryTag}[0,10]`

Obviously, you will need to substitute your own tag path for `[default]DatasetQueryTag`

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [October 14, 2022, 8:46am UTC](https://forum.inductiveautomation.com/t/assign-a-value-from-a-data-set-query-tag/65209/3 "2022-10-14T08:46:50Z")

</div>

Show us how you do it so we can figure out if there's something wrong. It's kinda hard to debug something that we can't see.

---

<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:** [October 14, 2022, 12:23pm UTC](https://forum.inductiveautomation.com/t/assign-a-value-from-a-data-set-query-tag/65209/4 "2022-10-14T12:23:48Z")

</div>

Just to clarify Justin's point:

Bracket syntax to access elements of a dataset is supported only in expression bindings or expression tags. Not in tag paths or anywhere else. It cannot be bidirectional. In jython, you use the `.getValueAt()` method as he shows.

---

<div class="post-metadata">

**Author:** ![SOPerator](https://avatars.discourse-cdn.com/v4/letter/s/838e76/32.png) [@SOPerator](https://forum.inductiveautomation.com/u/SOPerator)\
**Post date:** [October 14, 2022, 3:13pm UTC](https://forum.inductiveautomation.com/t/assign-a-value-from-a-data-set-query-tag/65209/5 "2022-10-14T15:13:36Z")

</div>

I'd been using an expression to do "Text: " + {[default]DatasetQueryTag}[0,10] and attempting to just bind the value of the tag's data directly to the component text (A label) but both were giving me the malformed tag path error

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [October 14, 2022, 3:27pm UTC](https://forum.inductiveautomation.com/t/assign-a-value-from-a-data-set-query-tag/65209/6 "2022-10-14T15:27:41Z")

</div>

I don't have a version 7.9 system setup for testing, and I haven't been able to recreate the error on version 8.1.20

Are you getting your tag path from here?:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/e/0e8abe9d5c5aea6bbed88dee6deb0f2152dfa690.png)

What does your tag quality look like in the tag browser?  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/3/534b6c839d44b4084745e29d88e6ddae8b526977.png)

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [October 14, 2022, 3:31pm UTC](https://forum.inductiveautomation.com/t/assign-a-value-from-a-data-set-query-tag/65209/7 "2022-10-14T15:31:29Z")

</div>

This doesn't seem like a datatype issue, but you could try: `"text:" + toString({[default]DatasetQueryTag}[0,10])`

---

<div class="post-metadata">

**Author:** ![SOPerator](https://avatars.discourse-cdn.com/v4/letter/s/838e76/32.png) [@SOPerator](https://forum.inductiveautomation.com/u/SOPerator)\
**Post date:** [October 14, 2022, 4:03pm UTC](https://forum.inductiveautomation.com/t/assign-a-value-from-a-data-set-query-tag/65209/8 "2022-10-14T16:03:36Z")

</div>

Yeah, I get the tag path from the 7.9 equivalent of where you're grabbing it from

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/2/c237386d916388cae492a1fc83f07781df4030cf.png)  
I think the issue may be with the [RecordDate] brackets part, that seems to be what is causing the error but I'm not sure how else to grab a value from a specific column, since I'm using the format the tag selection in the expression menu uses.

Tag diagnostics seem okay too

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/6/76e9ac034d953c3bfd717b04fa9eef8f05c5e7ed.png)

Also, toString didn't seem to help either unfortunately

---

<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:** [October 14, 2022, 4:13pm UTC](https://forum.inductiveautomation.com/t/assign-a-value-from-a-data-set-query-tag/65209/9 "2022-10-14T16:13:06Z")

</div>

You include the column name, as a string constant, instead of the column index in the latter brackets. Like so:

```auto
{[provider]path/to/dataset/tag}[0,'RecordDate']

```

If there is a chance the dataset is empty, wrap all of that with try(), like so:

```auto
try({[provider]path/to/dataset/tag}[0,'RecordDate'], someFallbackValue)

```

Make sure the fallback value is the same data type you normally get from the column.

See the v7.9 docs:

[https://docs.inductiveautomation.com/display/DOC79/Expression+Overview+and+Syntax#ExpressionOverviewandSyntax-DatasetAccess](https://docs.inductiveautomation.com/display/DOC79/Expression+Overview+and+Syntax#ExpressionOverviewandSyntax-DatasetAccess)
