Text and tag value in a ternary expression?

Is there a way to have a ternary expression output a string of text and a tag value?

([BATT_PER]<(21-[HOUR_0_23])*4?("dead at "([HOUR_0_23]):"")

Don’t mind the actual logic, it’s a quick example. This is the part I can’t get to work:

"dead at "([HOUR_0_23])

I’ve tried countless combinations of quotes and parentheses but all I get is either nothing or “dead at [HOUR_0_23]”. Am I missing something?

Welcome to this forum.

I have tried this: “Dead at” : (([BATT_PER] < 20)? 1:0), and this worked for me.
Please let me know if you face any issues or if it meets your query.

Hey Boshra – thanks for the suggestion! The issue is that I need the text to be displayed conditionally, too.

What I ended up doing is just putting two expressions next to each other – one for text and one for the value, like this:

([BATT_PER]<(21-[HOUR_0_23])*4?"dead at ":"")([BATT_PER]<(21-[HOUR_0_23])*4?[HOUR_0_23]:"")

Feels kludgy but it works

1 Like