# Getting a machine's speed while running

**URL:** <https://forum.inductiveautomation.com/t/getting-a-machines-speed-while-running/42447>\
**Category:** Ignition\
**Tags:** ignition80, scripting\
**Created:** [January 20, 2021, 4:54pm UTC](https://forum.inductiveautomation.com/t/getting-a-machines-speed-while-running/42447 "2021-01-20T16:54:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wci.jgiese](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wci.jgiese/32/50225_2.png) [@wci.jgiese](https://forum.inductiveautomation.com/u/wci.jgiese)\
**Post date:** [January 20, 2021, 4:54pm UTC](https://forum.inductiveautomation.com/t/getting-a-machines-speed-while-running/42447/1 "2021-01-20T16:54:10Z")

</div>

Trying to figure out how I can get from historian the average speed of our machines while running from a script and return it over a Web Dev page.

We have a simple tag that tracks speed with historian enabled. However when I run a query on this it gives me more or less the attained average over X period including 0s. So if the machine ran an average of 400 RPM for 12 hours and was off 12 hours I can only get 200RPM average in a 24 hour period from historian queries. I want that 400 avg it was running when it was actually running.

I can’t seem to figure out how to build they query to give me what I’m looking for is it even possible to do this from historian scripts?

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [January 20, 2021, 5:30pm UTC](https://forum.inductiveautomation.com/t/getting-a-machines-speed-while-running/42447/2 "2021-01-20T17:30:42Z")

</div>

If you have a machine running tag along with the speed I would pull both with a query, then loop the dataset building a new dataset where machine running=1

---

<div class="post-metadata">

**Author:** ![wci.jgiese](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wci.jgiese/32/50225_2.png) [@wci.jgiese](https://forum.inductiveautomation.com/u/wci.jgiese)\
**Post date:** [January 20, 2021, 5:35pm UTC](https://forum.inductiveautomation.com/t/getting-a-machines-speed-while-running/42447/3 "2021-01-20T17:35:24Z")

</div>

We do track a running state 1 or 0. That was an approach I thought of in theory but was not sure how to execute in practice. How can I mix two historian tags in the same dataset?

Right now I’m using queryTagHistory. Is there a different method I should use that could bring back timestamp, bpm, and runstate?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/3/43c19118c3106a7518414dc0471d9d20a0c97cb6.png)

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [January 20, 2021, 5:40pm UTC](https://forum.inductiveautomation.com/t/getting-a-machines-speed-while-running/42447/4 "2021-01-20T17:40:10Z")

</div>

paths is a list.  
so you just add more to the list and it will return them in wide format.

> tagpaths = ['path\to\tag1','path\to\tag2']  
> retDS = system.tag.queryTagHistory(paths=tagpaths,returnSize=returnSizeVar)

Also it isn't a good idea to use names for variables like dataSet.

---

<div class="post-metadata">

**Author:** ![wci.jgiese](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wci.jgiese/32/50225_2.png) [@wci.jgiese](https://forum.inductiveautomation.com/u/wci.jgiese)\
**Post date:** [January 20, 2021, 5:46pm UTC](https://forum.inductiveautomation.com/t/getting-a-machines-speed-while-running/42447/5 "2021-01-20T17:46:11Z")

</div>

you are correct in general using reserved keywords or types is not ideal. But I copy pasted from their documentation so 🤷🏻‍♂️ lol

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/9/29eb8fd97b40f6e97deabd7808fb719c311f2da4.png)
