# Calculating KPI based on timerange defined by the user

**URL:** <https://forum.inductiveautomation.com/t/calculating-kpi-based-on-timerange-defined-by-the-user/90140>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [May 9, 2024, 5:46am UTC](https://forum.inductiveautomation.com/t/calculating-kpi-based-on-timerange-defined-by-the-user/90140 "2024-05-09T05:46:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marko\_Petrovic](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@Marko\_Petrovic](https://forum.inductiveautomation.com/u/Marko_Petrovic)\
**Post date:** [May 9, 2024, 5:46am UTC](https://forum.inductiveautomation.com/t/calculating-kpi-based-on-timerange-defined-by-the-user/90140/1 "2024-05-09T05:46:07Z")

</div>

Hello all 🙂  
I'm new to perspective, so this question might be easy to answer. I have one KPI defined that is calculated every 10 seconds and simply returns a 1 or a 0.

What I want to do now is based on the user-defined time range on a dashboard to calculate how often it was 0 or 1 to show a percentage value when it was 1 in that time range. Can someone point me in the right direction on how to do that?

Thanks a lot

---

<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:** [May 9, 2024, 6:07am UTC](https://forum.inductiveautomation.com/t/calculating-kpi-based-on-timerange-defined-by-the-user/90140/2 "2024-05-09T06:07:06Z")

</div>

Where is the information stored? Database? What is the table structure (column names and data types), etc.?

---

<div class="post-metadata">

**Author:** ![Marko\_Petrovic](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@Marko\_Petrovic](https://forum.inductiveautomation.com/u/Marko_Petrovic)\
**Post date:** [May 9, 2024, 6:46am UTC](https://forum.inductiveautomation.com/t/calculating-kpi-based-on-timerange-defined-by-the-user/90140/3 "2024-05-09T06:46:34Z")

</div>

The data tags are coming from a MQTT Engine. I thought to historize them so I can access then the historical info.

Column: IsActive  
DataType: Boolean

---

<div class="post-metadata">

**Author:** ![hunterdg](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/hunterdg/32/67774_2.png) [@hunterdg](https://forum.inductiveautomation.com/u/hunterdg)\
**Post date:** [May 9, 2024, 7:18am UTC](https://forum.inductiveautomation.com/t/calculating-kpi-based-on-timerange-defined-by-the-user/90140/4 "2024-05-09T07:18:18Z")

</div>

historize it, query the history _as stored_ via tag history binding, parse/evaluate the data with a script transform on the history binding

this [Simple Rectangle Chart](https://inductiveautomation.com/exchange/2575/overview) may also be useful.

---

<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:** [May 9, 2024, 9:56am UTC](https://forum.inductiveautomation.com/t/calculating-kpi-based-on-timerange-defined-by-the-user/90140/5 "2024-05-09T09:56:09Z")

</div>

> [@Marko\_Petrovic](#):
>
> Column: IsActive  
> DataType: Boolean

You're missing t\_stamp, machineId, partsCount, rejectCount, runningRecipe, etc. Expand your thinking! What else would be useful for reports?

What Ignition version and modules are you using?  
Do you have a Historian licence?

---

<div class="post-metadata">

**Author:** ![Marko\_Petrovic](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@Marko\_Petrovic](https://forum.inductiveautomation.com/u/Marko_Petrovic)\
**Post date:** [May 15, 2024, 1:15pm UTC](https://forum.inductiveautomation.com/t/calculating-kpi-based-on-timerange-defined-by-the-user/90140/6 "2024-05-15T13:15:24Z")

</div>

That's how it worked! Thanks a lot.
