# Turn {this.props.data\[0\].Hour.value} into {this.props.data\[THIS ROW\].Hour.value}

**URL:** <https://forum.inductiveautomation.com/t/turn-this-props-data-0-hour-value-into-this-props-data-this-row-hour-value/64726>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [October 1, 2022, 12:43am UTC](https://forum.inductiveautomation.com/t/turn-this-props-data-0-hour-value-into-this-props-data-this-row-hour-value/64726 "2022-10-01T00:43:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![I\_Rock\_Well](https://avatars.discourse-cdn.com/v4/letter/i/7c8e57/32.png) [@I\_Rock\_Well](https://forum.inductiveautomation.com/u/I_Rock_Well)\
**Post date:** [October 1, 2022, 12:43am UTC](https://forum.inductiveautomation.com/t/turn-this-props-data-0-hour-value-into-this-props-data-this-row-hour-value/64726/1 "2022-10-01T00:43:35Z")

</div>

I am trying to create a table for defects and throughput number by hour while making it as parametererable (is that a word) than possible.  
My specific question: how to i turn {this.props.data[0].Hour.value} into a something that gets the hour valuie of the row that I am concerned about?

---

<div class="post-metadata">

**Author:** ![jespinmartin1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jespinmartin1/32/57175_2.png) [@jespinmartin1](https://forum.inductiveautomation.com/u/jespinmartin1)\
**Post date:** [October 1, 2022, 5:14am UTC](https://forum.inductiveautomation.com/t/turn-this-props-data-0-hour-value-into-this-props-data-this-row-hour-value/64726/2 "2022-10-01T05:14:38Z")

</div>

Using expression is not the way. I don't know your final need but you might be interested in prop selected row data of the table.  
Inside data you will find the row that changes everytime you select a row.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/2/1276264506f0c94c14a79a14eece5259759758d6.png)

---

<div class="post-metadata">

**Author:** ![I\_Rock\_Well](https://avatars.discourse-cdn.com/v4/letter/i/7c8e57/32.png) [@I\_Rock\_Well](https://forum.inductiveautomation.com/u/I_Rock_Well)\
**Post date:** [October 1, 2022, 7:26pm UTC](https://forum.inductiveautomation.com/t/turn-this-props-data-0-hour-value-into-this-props-data-this-row-hour-value/64726/3 "2022-10-01T19:26:42Z")

</div>

Not at work so I can't test it. but I do think it will work for my needs.

Here is the query I plan on running:

```auto
SELECT sum([Tape_Reject]) 
FROM [Ignition].[dbo].[Line1_Reject_LH]
Where datepart(hh,t_stamp) BETWEEN :myValueX and :myValueY
  AND datepart(day,t_stamp) = day(getdate())  

```

My valueX and myValueY are hours of a shift. In the end I want a table with 8 rows. First column will be the HOUR of the shift, so 1-8. Then I have a bunch of defect data like the Tape\_Reject in the example above. I want to find a way that I can duplicate data[0} without having to change the hours manually.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [October 1, 2022, 7:45pm UTC](https://forum.inductiveautomation.com/t/turn-this-props-data-0-hour-value-into-this-props-data-this-row-hour-value/64726/4 "2022-10-01T19:45:58Z")

</div>

> [@I\_Rock\_Well](#):
>
> `SELECT sum([Tape_Reject]) `

That query will return only one column, the sum of Tape\_Reject. There will be no hour value in your table.  
Where are you seeing `{this.props.data[0].Hour.value}`?

If you want to return an Hour column then your query would look something like,

```sql
SELECT 
    datepart(hh, t_stamp) AS 'Hour', 
    sum([Tape_Reject]) AS 'Tape Reject'
FROM [Ignition].[dbo].[Line1_Reject_LH]
WHERE datepart(hh,t_stamp) BETWEEN :myValueX AND :myValueY
  AND datepart(day,t_stamp) = day(getdate()) 
GROUP BY Hour

```

I haven't tested this.

* * *

> I want to find a way that I can duplicate data[0} without having to change the hours manually.

I still don't understand this sentence. Create a table of what you've got and what you want. Use the \</\> to apply preformatting to keep the columns lined up.

---

<div class="post-metadata">

**Author:** ![I\_Rock\_Well](https://avatars.discourse-cdn.com/v4/letter/i/7c8e57/32.png) [@I\_Rock\_Well](https://forum.inductiveautomation.com/u/I_Rock_Well)\
**Post date:** [October 1, 2022, 11:42pm UTC](https://forum.inductiveautomation.com/t/turn-this-props-data-0-hour-value-into-this-props-data-this-row-hour-value/64726/6 "2022-10-01T23:42:46Z")

</div>

I guess I approched it all wrong. I created a table in perspective, and planned on having a query for each cell. My end goal is something like this:

Shift 1  
Hour Parts Produced Defect 1 Defect 2  
1 58 0 2  
2 47 3 5  
... ... ... ....

The hour 1 for shift 1 would be any parts and defects between 7am and 8am. The sql database regesters parts and defects as "1"s.  
Is there a way to do that in SQL? That would blow my mind!!!

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [October 2, 2022, 1:21am UTC](https://forum.inductiveautomation.com/t/turn-this-props-data-0-hour-value-into-this-props-data-this-row-hour-value/64726/7 "2022-10-02T01:21:35Z")

</div>

> [@I\_Rock\_Well](#):
>
> The hour 1 for shift 1 would be any parts and defects between 7am and 8am. The sql database regesters parts and defects as "1"s.  
> Is there a way to do that in SQL? That would blow my mind!!!

What do you mean the database registers defects as “1”s. Does that mean the column is a flag type where `1 = Defect` and `0 = Non-Defect`? Or does it mean something different?

Your query should return all data you want displayed in the table.

What I believe you are looking for is achieved with a modification to @Transistor’s query

```auto
SELECT 
    datepart(hh, t_stamp) AS 'Hour', 
    sum([Tape_Reject]) AS 'Tape Reject',
    sum([Defect_1]) AS 'Defect 1',
    sum([Defect_2]) AS 'Defect 2'
FROM [Ignition].[dbo].[Line1_Reject_LH]
WHERE datepart(hh,t_stamp) BETWEEN :myValueX AND :myValueY
  AND datepart(day,t_stamp) = day(getdate()) 
GROUP BY Hour

```

It really depends on what your data looks like, I have no doubt though that what you want can be handled in SQL
