Is there a way to map enums to values?

Options

I have a method of mapping numbers to text:

-1 → "unknown"
0 → "very low"
1 → "low"
2 → "high"
3 → "very high"

I want to be able to create a graph (bar, or line, or etc) using these values, but I want the label for the number to show as the associated text. I tried using beast mode to convert the numbers to text, but then the graph uses the text value instead of the integer value. How can I retain the value of the number while using the text for the actual graph label. (i.e. the x or y axis would show the text not the number)

(CASE
WHEN risk_level = 0 THEN 'Very Low'
WHEN risk_level = 1 THEN 'Low'
WHEN risk_level = 2 THEN 'High'
WHEN risk_level = 3 THEN 'Very High'
WHEN risk_level = -1 THEN 'Unkown'
END)

Best Answer

  • MarkSnodgrass
    Answer ✓
    Options

    You are right, that doesn't look great. I was expecting your "x-axis" to be grouped by day and not by each individual time element. You might need to create a beast mode for your dates and use the DATE() function to remove the time element. This would consolidate things a bit. Add this date beast mode to your chart and to the sorting to make it go in the correct direction.

    **Check out my Domo Tips & Tricks Videos

    **Make sure to <3 any users posts that helped you.
    **Please mark as accepted the ones who solved your issue.

Answers

  • MarkSnodgrass
    Options

    I would put your numerical value field in the values field of the card and then put your text field in the Tooltip Field and then use the Data Label Settings in the Chart Properties to display the Tooltip Field.

    **Check out my Domo Tips & Tricks Videos

    **Make sure to <3 any users posts that helped you.
    **Please mark as accepted the ones who solved your issue.
  • osama
    osama Member
    Options

    Is there a way to get the text value to appear in the y axis of a bar graph? It would make it easier to see what is what. Also, some values are just not showing when the label is in the graph data itself.

  • MarkSnodgrass
    Options

    The y-axis can't be text for this type of graph. You might want to consider using the heat map chart type. You can use your text labels for the "y-axis" and then use your numerical values in the sorting properties to get it to be displayed in the low to high order that you want. Here's the KB article.

    https://domo-support.domo.com/s/article/360042924634?language=en_US

    **Check out my Domo Tips & Tricks Videos

    **Make sure to <3 any users posts that helped you.
    **Please mark as accepted the ones who solved your issue.
  • osama
    osama Member
    Options

    Heat maps don't seem to work great with dates unfortunately. It's also pretty hard to see.

  • MarkSnodgrass
    Answer ✓
    Options

    You are right, that doesn't look great. I was expecting your "x-axis" to be grouped by day and not by each individual time element. You might need to create a beast mode for your dates and use the DATE() function to remove the time element. This would consolidate things a bit. Add this date beast mode to your chart and to the sorting to make it go in the correct direction.

    **Check out my Domo Tips & Tricks Videos

    **Make sure to <3 any users posts that helped you.
    **Please mark as accepted the ones who solved your issue.