String in a cell of a query to a label transform

What I am trying to show
image

what I am showing right now from binding the label to my query:
image

the example result of my query:
image

I am not really sure how to transform this.
image

my query is receiving parameters to figure out which message to show

If you are only returning a single message from your query, you could change the query to be a scalar query so it returns a value and not a dataset.

1 Like

thanks
I like the new profile pic/logo you have too

I also used

if value < 0:
 value=" "
  return value
else:
  return value
if value < 0:
    value = " "
return value

Is more pythonic, no need for the else. Though, based on your original post, this seems to not be the correct test. What do you think you’re testing for with if value < 0?

I was trying to test for null haha, but I couldn’t get it to work, then less than zero “worked” haha

In Python it’s
if myVariable is None:.

In expression language it’s
if(isNull(myVariable), ..., ...)

For your original problem:
[{"Description": "10 CB212 control voltage 24VDC +12 tripped "}]
you’ve got a dictionary { } inside a list [ ]. You can retrieve the message string:

  1. Switch the returned format to JSON (Document) format.
  2. Add a script transform.
  3. Modify the return value line to return value[0]['Description'].
    The [0] is because the dictionary is the 0th element in the list.

You’ve already got a fix using the Scaler option but this may come in handy for other tasks.
`

1 Like

Thanks very much for the additional information.

That makes sense.

You could do it as a one line with:

return value if value is not None else " "

Though that is a little cryptic in this case, but it’s nice to know it’s a possibility.

Also be careful because, None is not equivilent to ""

" " is not equal to "" either. Why return a space and not an empty string?

Yeah, I know. I was more cautioning against the thought that:

if value == "" was the same as if value is none

I used " " in this case because that is what the OP used

If you were asking me, I didn’t have a particular reason.

I usually use a space. I have a vague memory of some software skipping my cell when it was an empty string, but I don’t recall the specifics. Or maybe it was just the abundance of null errors I used to get programming Java, and no idea where they were haha

I am not sure.