I’m drawing a blank on writing a script in a report and can’t seem to find anything online. I’m trying filter downtimes that are greater than 2.0 minutes with a checkbox. I have the parameter for the checkbox in the report as Notes. When the checkbox is selected on the window, I am wanting the report to show all the downtimes. When the checkbox is unchecked I am wanting only the downtimes that are greater than 2.0 minutes to appear.
line = data["Line"]
area = data["Area"]
site = data["Site"]
settings = system.production.createAnalysisSettings()
settings.setAnalysisProvider("Downtime")
settings.addFilter("StartDate", system.db.dateFormat(data["StartDate"], "yyyy-MM-dd HH:mm:ss"))
settings.addFilter("EndDate", system.db.dateFormat(data["EndDate"], "yyyy-MM-dd HH:mm:ss"))
settings.addFilter("Line", line)
settings.addFilter("Area", area)
settings.addFilter("Site", site)
settings.addCompareBy("Line")
settings.addCompareBy("Area")
settings.addCompareBy("Site")
settings.addDataPoint("Line")
settings.addDataPoint("Area")
resultData = []
results = system.production.getAnalysisResults(settings)
for row in system.dataset.toPyDataSet(results.getTableResults()):
line = row["Line"]
area = row["Area"]
settings = system.production.createAnalysisSettings()
settings.setAnalysisProvider("Downtime")
settings.addFilter("StartDate", system.db.dateFormat(data["StartDate"], "yyyy-MM-dd HH:mm:ss"))
settings.addFilter("EndDate", system.db.dateFormat(data["EndDate"], "yyyy-MM-dd HH:mm:ss"))
settings.addFilter("Line", line)
settings.addFilter("Area", area)
settings.addCompareBy("Downtime Event")
settings.addCompareBy("Factor:Shift Rotation")
settings.addCompareBy("Cell Name")
settings.addCompareBy("Reason")
settings.addCompareBy("Area")
if data["Notes"]:
settings.addFilter("Note", "Include")
else:
settings.addFilter("Note", "Exclude Default")
settings.addDataPoint("Note")
settings.addDataPoint("Downtime Minutes (Time Format)")
settings.addDataPoint("Downtime Minutes")
settings.addDataPoint("End Time")
tableData = system.production.getAnalysisResults(settings).getTableResults()
resultData.append([line, tableData])
data['RunData'] = system.dataset.toDataSet(["Line", "TableData"], resultData)