Jump to content

Max Employees on Schedule

Lindsay Longnecker

Recommended Posts

I have a scatter plot that graphs all employees on the X-axis and their associated start and end times on the Y-axis. I would like to add a horizontal line at the time on the Y-axis that the max employees are working and is lablelled with that number of employees. Is this possible using a custom expression in Lines & Curves
Link to comment
Share on other sites

I tried with the following data set:


Use the following IronPython Script (Considering 12 AM = 0 in the array)

from Spotfire.Dxp.Data import *


tableName='Data Table'

columnToFetch='Start Time'

columnToFetch2='End Time'


rowCount = activeTable.RowCount

arr = []

rowsToInclude = IndexSet(rowCount,True)

cursor1 = DataValueCursor.CreateFormatted(activeTable.Columns[columnToFetch])

cursor2 = DataValueCursor.CreateFormatted(activeTable.Columns[columnToFetch2])


for row in activeTable.GetRows(rowsToInclude,cursor1,cursor2):

rowIndex = row.Index

temp = [0]*24


val1 = int(cursor1.CurrentValue)

val2 = int(cursor2.CurrentValue)


for i in range(val1,val2):




output_=[sum(i) for i in zip(*arr)] #gives sum of column values


Document.Properties["maxEmployee"] = output_.index(max(output_))The Value of output_=[0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 7, 7, 9, 10, 11, 11, 13, 12, 10, 8, 4, 3,0]

Max value is at 17th index, so max employees would be at 5 PM.

And used the following custom expression in the Horizontal line

${maxEmployee}Final result:

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...