Thousands Separator in Beast Mode
Hi Everyone,
I'd love to add a thousands separator to the formulas below. I searched and tried the solutions out there for hours, but had no luck. I'd appreciate it if you could help me with this.
CASE
WHEN `Objective` like 'Awareness' AND `Campaign Name`like '%MOTHERS%' AND `Platform` like '%FB%' AND SUM(`impressions`) > 300002 THEN CONCAT('<div style="background-color:#bbe491; width: 100%; height:100%; margin:-20px; padding:20px"><a href="#">',ROUND((SUM(`impressions`)),0),'</a></div>')
END
Comments
-
I'm assuming you are wanting to do this for a summary number since you can use the formatting options on a field when you drag into use if it is a numeric field.
There a number of methods you can use to do this. If you search for custom summary number in the Dojo, you will see some other examples. Here is what I created that accounts for if the number has a decimal in it or not. My end result displays a number as $1.45M, for example. You can tweak this to have it not abbreviate and insert a comma where necessary.
CONCAT(
CASE WHEN INSTR(SUM(`G/U Incurred`),'.') > 0 THEN
/*Number contains decimal places*/
(
CASE
WHEN INSTR(SUM(`G/U Incurred`),'.') = 13 THEN /*xxx billion*/
CONCAT(LEFT(SUM(`G/U Incurred`),3),'.',SUBSTRING(SUM(`G/U Incurred`),4,2),'B')
WHEN INSTR(SUM(`G/U Incurred`),'.') = 12 THEN /*xx billion*/
CONCAT(LEFT(SUM(`G/U Incurred`),2),'.',SUBSTRING(SUM(`G/U Incurred`),3,2),'B')
WHEN INSTR(SUM(`G/U Incurred`),'.') = 11 THEN /*x billion*/
CONCAT(LEFT(SUM(`G/U Incurred`),1),'.',SUBSTRING(SUM(`G/U Incurred`),2,2),'B')
WHEN INSTR(SUM(`G/U Incurred`),'.') = 10 THEN /*xxx million*/
CONCAT(LEFT(SUM(`G/U Incurred`),3),'.',SUBSTRING(SUM(`G/U Incurred`),4,2),'M')
WHEN INSTR(SUM(`G/U Incurred`),'.') = 9 THEN /*xx million*/
CONCAT(LEFT(SUM(`G/U Incurred`),2),'.',SUBSTRING(SUM(`G/U Incurred`),3,2),'M')
WHEN INSTR(SUM(`G/U Incurred`),'.') = 8 THEN /*x million*/
CONCAT(LEFT(SUM(`G/U Incurred`),1),'.',SUBSTRING(SUM(`G/U Incurred`),2,2),'M')
WHEN INSTR(SUM(`G/U Incurred`),'.') = 7 THEN /*xxx thousand*/
CONCAT(LEFT(SUM(`G/U Incurred`),3),'.',SUBSTRING(SUM(`G/U Incurred`),4,2),'K')
WHEN INSTR(SUM(`G/U Incurred`),'.') = 6 THEN /*xx thousand*/
CONCAT(LEFT(SUM(`G/U Incurred`),2),'.',SUBSTRING(SUM(`G/U Incurred`),3,2),'K')
WHEN INSTR(SUM(`G/U Incurred`),'.') = 5 THEN /*x thousand*/
CONCAT(LEFT(SUM(`G/U Incurred`),1),'.',SUBSTRING(SUM(`G/U Incurred`),2,2),'K')
END)
ELSE
/*Number has NO decimal places */
(
CASE
WHEN LENGTH(SUM(`G/U Incurred`)) = 12 THEN /*xxx billion*/
CONCAT(LEFT(SUM(`G/U Incurred`),3),'.',SUBSTRING(SUM(`G/U Incurred`),4,2),'B')
WHEN LENGTH(SUM(`G/U Incurred`)) = 11 THEN /*xx billion*/
CONCAT(LEFT(SUM(`G/U Incurred`),2),'.',SUBSTRING(SUM(`G/U Incurred`),3,2),'B')
WHEN LENGTH(SUM(`G/U Incurred`)) = 10 THEN /*x billion*/
CONCAT(LEFT(SUM(`G/U Incurred`),1),'.',SUBSTRING(SUM(`G/U Incurred`),2,2),'B')
WHEN LENGTH(SUM(`G/U Incurred`)) = 9 THEN /*xxx million*/
CONCAT(LEFT(SUM(`G/U Incurred`),3),'.',SUBSTRING(SUM(`G/U Incurred`),4,2),'M')
WHEN LENGTH(SUM(`G/U Incurred`)) = 8 THEN /*xx million*/
CONCAT(LEFT(SUM(`G/U Incurred`),2),'.',SUBSTRING(SUM(`G/U Incurred`),3,2),'M')
WHEN LENGTH(SUM(`G/U Incurred`)) = 7 THEN /*x million*/
CONCAT(LEFT(SUM(`G/U Incurred`),1),'.',SUBSTRING(SUM(`G/U Incurred`),2,2),'M')
WHEN LENGTH(SUM(`G/U Incurred`)) = 6 THEN /*xxx thousand*/
CONCAT(LEFT(SUM(`G/U Incurred`),3),'.',SUBSTRING(SUM(`G/U Incurred`),4,2),'K')
WHEN LENGTH(SUM(`G/U Incurred`)) = 5 THEN /*xx thousand*/
CONCAT(LEFT(SUM(`G/U Incurred`),2),'.',SUBSTRING(SUM(`G/U Incurred`),3,2),'K')
WHEN LENGTH(SUM(`G/U Incurred`)) = 4 THEN /*x thousand*/
CONCAT(LEFT(SUM(`G/U Incurred`),1),'.',SUBSTRING(SUM(`G/U Incurred`),2,2),'K')
END
)
END
)G/U Incurred is the field I was evaluating in this instance.
**Check out my Domo Tips & Tricks Videos
**Make sure to any users posts that helped you.
**Please mark as accepted the ones who solved your issue.2 -
🤮
0 -
You just need to split up your
ROUND((SUM(`impressions`)),0)
It's already inside of a CONCAT(), so you need to separate the thousands from the hundreds. Try putting this instead
ROUND(SUM(`impressions`)/1000,0),',',MOD(SUM(`impressions`),1000)
This will not add a second comma if you exceed 999,999 impressions though. It will also look like this 0,285 if there are less then 1000 impressions (285) in my example. However, your case statement seemed to require there to be more than 300,002 impressions. If you need the formula to handle a wider range of numbers, then you will need to use something more similar to what @MarkSnodgrass has suggested.
Another option, if you are using a Dashboard, is to use a "Single value" card as your "summary number". Just place this on top of your visual. You can specify if you don't want the value to be abbreviated. By default the card would show 1,640 as 1.64K. However, you can change the Divide Value By to "None" to get 1,640 to display
0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.6K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 102 SQL DataFlows
- 626 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 753 Beast Mode
- 61 App Studio
- 41 Variables
- 692 Automate
- 177 Apps
- 456 APIs & Domo Developer
- 49 Workflows
- 10 DomoAI
- 38 Predict
- 16 Jupyter Workspaces
- 22 R & Python Tiles
- 398 Distribute
- 115 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 130 Manage
- 127 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 11 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 110 Community Announcements
- 4.8K Archive