Real-Time Expressions: Map Values to Emojis


Overview

Map a value or value range to another value such as an emoji character. This operation utilizes the map operator, :, as well as the union operator, |. 

Syntax


Replace a single value range with a character
=([data stream] <operator> <value> : <character>) | [data stream] 

Replace multiple value ranges with different characters
=([data stream] <operator1> <value1> : <character1>) | ([data stream] <operator2> <value2> : <character2>) | ([data stream] <operator3> <value3> : <character3>)

Example

We want to map a temperature stream to one of three emojis, a fire icon if the temperature is greater than 80 °F, a snowflake icon if the temperature is less than 45 °F, and a smiley face if the temperature is between 80 °F and 45 °F. 


In the example above, [Brentwood Temperature(F)] is the data stream that will be transformed. A single value map replacement can be performed using the following real-time expression:

=([Brentwood Temperature(F)] > 80:"selected emoji") | ([Brentwood Temperature(F)])

If you are running on a Mac, you can use the shortcut "Control + Command + Spacebar" to pop-up the emoji window list. Otherwise, you can copy and paste the desired emoji from http://getemoji.com/.

The map operator will replace values from a specific range with the selected emoji - this part of the expression: ([Brentwood Temperature(F)] > 80:"selected emoji").

The join operator, | ([Brentwood Temperature(F)]), gives the left operand higher priority. All replacements of values > 80 will be joined with the original data stream, [Brentwood Temperature(F)], creating a single data stream that shows the fire icon when the temperature is greater than 80 and the temperature number otherwise.

Multiple value map replacements can be performed using the following:

=([Brentwood Temperature(F)] > 80:"selected emoji 1") | ([Brentwood Temperature(F)] < 45:"selected emoji 2")|([Brentwood Temperature(F)]:"selected emoji 3")

This will create a data stream that will only show one of three emojis based on the numeric range. The map operation on the far right will replace any value not in the first two ranges with "selected emoji 3".


Feedback and Knowledge Base