# Get value from an object with complex title

**URL:** <https://discourse.nodered.org/t/get-value-from-an-object-with-complex-title/80622>\
**Category:** General\
**Created:** [17 August 2023 01:18 UTC](https://discourse.nodered.org/t/get-value-from-an-object-with-complex-title/80622 "2023-08-17T01:18:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lars-the-tinkerer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lars-the-tinkerer/32/82091_2.png) [@Lars-the-tinkerer](https://discourse.nodered.org/u/Lars-the-tinkerer)\
**Post date:** [17 August 2023 01:18 UTC](https://discourse.nodered.org/t/get-value-from-an-object-with-complex-title/80622/1 "2023-08-17T01:18:01Z")

</div>

I'm sorry if this has been answered already but I can't seem to find my specific case.

I fetch values from an SQL database and want to use these in graphs and charts of the dashboard module. For some values I sum various fields in a single SQL statement and want to use that combined output.

I know you can transfer values using a function or change node with a payload statement like "msg.payload.item"

However with complex SQL statements it tells me the node is invalid.

The SQL statement is something like:

```auto
msg.topic ='select (`Solar_zuid`+`Solar_west`+`Solar_oost`+`Solar_center`+`Solar_new`) from power order by Timestamp desc limit 1'
return msg;

```

What I would get is something like:  
`(`Solar\_zuid`+`Solar\_west`+`Solar\_oost`+`Solar\_center`+`Solar\_new`): 1234 }`

Obviously I just need that value "1234".

Thanks for your help!

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [17 August 2023 01:23 UTC](https://discourse.nodered.org/t/get-value-from-an-object-with-complex-title/80622/2 "2023-08-17T01:23:05Z")

</div>

Welcome to the forum Lars.

Give your calculated value an alias:

```auto
msg.topic ='select (`Solar_zuid`+`Solar_west`+`Solar_oost`+`Solar_center`+`Solar_new`) as total from power order by Timestamp desc limit 1'

```

The output should be an object `{"total":1234}`  
and the value should be `msg.payload.total`

Edit - the output is probably an array of one or more objects so you may need msg.payload[0].total

---

<div class="post-metadata">

**Author:** ![Lars-the-tinkerer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lars-the-tinkerer/32/82091_2.png) [@Lars-the-tinkerer](https://discourse.nodered.org/u/Lars-the-tinkerer)\
**Post date:** [17 August 2023 12:29 UTC](https://discourse.nodered.org/t/get-value-from-an-object-with-complex-title/80622/3 "2023-08-17T12:29:03Z")

</div>

Thanks Jbudd that did the trick!

So simple it turns out! You just need to know it 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [16 October 2023 12:29 UTC](https://discourse.nodered.org/t/get-value-from-an-object-with-complex-title/80622/4 "2023-10-16T12:29:17Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
