Why cannot access the data from a dataset

Not sure why I can’t access the value from the first column at the first row with the expression below
if({Conveyor.FaultedTime} [1] = none, x, y)

All I am trying to do is:
If ConveyorFaultedTime is empty
execute x
Else
execute y

Subscripts start with zero.

2 Likes

Apart from Phil’s comment, shouldn’t your expression be
if({Conveyor.FaultedTime}[1] = null, x, y)?

Use ‘null’ in Expression Language. Use ‘None’ (capital N) in Python.


Tip: use the </> code formatting button when posting code. It will indent properly (important for Python) and give syntax highlighting. You can use the 🖉 edit link to fix your post.

2 Likes

Also if you want a specific column of a specific row you want two arguments like
if({Conveyor.FaultedTime} [0,0] = null, x, y)
or
if({Conveyor.FaultedTime} [0,'someColumnName'] = null, x, y)

1 Like

Thanks all for the replies. Additionally, how can I handle empty rows?

{Conveyor.FaultedTime} [0,1] = null

Does not seem to be working; I get the following error
Error executing expression binding

  1. don’t put any spaces beteween {Conveyor.FaultedTime} [0,1] , should look more like {Conveyor.FaultedTime}[0,1] Also I highly recommend using the column name for the second arugment - makes it more readable when you have to come back to it (and if you ever end up editing the dataset by adding or removing columns it will still work if its based on the column name).

  2. To handle empty rows my preferred method and I think the best practices method imo is to follow the python paradigm of trying first and asking for forgivness second. So maybe two custom properties are your best bet here. One that tries to get the data out if it exists or provides a fallback value if it does not looks like try({Conveyor.FaultedTime}[0, 1], "FALL BACK VALUE HERE"). So if there is a zero’th row, you will get it, otherwise you will get whatever the second argument of your try statement is when it doesn’t exist. Then in another custom property check out the value, you can add a case in case its the fallback value if desired, etc.

3 Likes

Thanks for the detailed explanation. It is working now.