Domo Idea Exchange - Beast Modes - Abbreviated Summary Number


Greetings! This is another post highlighting a beast mode from my Domo IDEAs conference session. This one covers how to format numbers a number in an abbreviated format.
Problem:
When concatenating a string with a number the resulting value is a string and unable to utilize Domo's built in formatting.
Solution:
This version only needs to check for length in increments of 3 to determine the correct units (Billions, Millions etc). The case statement goes in a descending order because the case statement will enter the condition that evaluates to true first. So every condition below the top one implies that the first condition is false.
- -- Author:
- -- Created:
- -- Last Modified:
- -- Description: Since the numbers are being concatenated with a string
- -- Default Domo number formatting is no longer possible. This will format the
- -- total of the `random_number` field based on how large the number is.
- -- ROUND will format the abbreviation to 2 decimal places.
- CONCAT(
- 'Total: ',
- -- CASE statements will evaluate the first expression it finds to be true and then exists.
- -- No further conditions are evaluated
- -- If >= 10 digits then it's in the billions
- -- It would need to be expanded to 13 for (T)rillions
- CASE WHEN LENGTH(ROUND(SUM(`random_number`), 0)) >= 10 THEN
- CONCAT(ROUND(SUM(`random_number`) / 1000000000, 2), 'B')
- -- 7 digits means Millions
- WHEN LENGTH(ROUND(SUM(`random_number`), 0)) >= 7 THEN
- CONCAT(ROUND(SUM(`random_number`) / 1000000, 2), 'M')
- -- 4-6 digits = thousands
- WHEN LENGTH(ROUND(SUM(`random_number`), 0)) >= 4 THEN
- CONCAT(ROUND(SUM(`random_number`) / 1000, 2), 'K')
- WHEN LENGTH(ROUND(SUM(`random_number`), 0)) <= 3 THEN
- ROUND(SUM(`random_number`), 0)
- WHEN SUM(`random_number`) IS NULL THEN 0
- ELSE ''
- END
- )
Note:
These beast modes only go to 100 Billion (12 digits). Any number higher would need to expand using the same logic for higher lengths.
**Did this solve your problem? Accept it as a solution!**
Comments
-
Here's a link to the video of my session outlining this beast mode: https://www.youtube.com/watch?v=gO8OLpsAk4M&index=6
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**1
Categories
- All Categories
- 2K Product Ideas
- 2K Ideas Exchange
- 1.6K Connect
- 1.3K Connectors
- 311 Workbench
- 7 Cloud Amplifier
- 9 Federated
- 3.8K Transform
- 655 Datasets
- 114 SQL DataFlows
- 2.2K Magic ETL
- 811 Beast Mode
- 3.3K Visualize
- 2.5K Charting
- 80 App Studio
- 45 Variables
- 770 Automate
- 190 Apps
- 481 APIs & Domo Developer
- 76 Workflows
- 23 Code Engine
- 36 AI and Machine Learning
- 19 AI Chat
- AI Playground
- AI Projects and Models
- 17 Jupyter Workspaces
- 408 Distribute
- 119 Domo Everywhere
- 279 Scheduled Reports
- 10 Software Integrations
- 142 Manage
- 138 Governance & Security
- 8 Domo Community Gallery
- 48 Product Releases
- 12 Domo University
- 5.4K Community Forums
- 41 Getting Started
- 31 Community Member Introductions
- 114 Community Announcements
- 4.8K Archive