# Scripting tag history and viewing

**URL:** <https://forum.inductiveautomation.com/t/scripting-tag-history-and-viewing/15484>\
**Category:** Ignition\
**Created:** [September 27, 2017, 6:26pm UTC](https://forum.inductiveautomation.com/t/scripting-tag-history-and-viewing/15484 "2017-09-27T18:26:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tim.schultz](https://avatars.discourse-cdn.com/v4/letter/t/71e660/32.png) [@tim.schultz](https://forum.inductiveautomation.com/u/tim.schultz)\
**Post date:** [September 27, 2017, 6:26pm UTC](https://forum.inductiveautomation.com/t/scripting-tag-history-and-viewing/15484/1 "2017-09-27T18:26:07Z")

</div>

I found the storeTagHistory function while browsing the API today, which looks pretty perfect for what my task at hand.

I was able to get the storeTagHistory working, using the snippet below (note that my history provider is ‘Process’). I’m creating a virtual KPI folder with a history tag called TestKPI inside of it. My question is, are these ‘virtual’ tags actually retained inside the historian? And, if so, how do I get them to appear in a tag tree or something similar that a user could view? Or do I need to create actual tags for that (I would assume memory tags set to historize)?

def storeKPI(tagName, value,tagTime):  
paths = [‘KPI/’+tagName]  
values = [value]  
quals = [192]  
dates = [tagTime]  
#Store the history with the variables declared above.  
system.tag.storeTagHistory(“Process”,“madeUpProvider”, paths, values,quals, dates)

def printHistory(tagName,startTime=’’,endTime=’’):  
newValues = system.tag.queryTagHistory(  
paths=[’[Process]KPI/’+tagName],  
aggregationMode=‘LastValue’,  
returnFormat=‘Tall’,  
startDate = startTime,  
endDate = endTime  
)  
for row in range(newValues.rowCount):  
print ‘%s:\t%s’%(newValues.getValueAt(row,3),newValues.getValueAt(row,1))

tagTime = system.date.now()  
tagName = ‘TestKPI’  
value = 1357  
#storeKPI(tagName,value,tagTime)  
#Need to wait after calling storeKPI or our result won’t show up.  
printHistory(tagName)
