How do I put a comma in multiple summary numbers?

How do I fix my beastmode to add commas to my dollar amounts?
CONCAT('Total Revenue - $',ROUND(SUM(`Revenue`)),'<br>Total Net Profit - $',ROUND(SUM(`Net Profit`)))
Result:
Total Revenue - $54783
Total Profit - $12455
But what I want to see is:
Total Revenue - $54,783
Total Profit - $12,455
Thank you,
Nicole
Comments
-
You might check out this thread. It's a few years old but I think it still applies today.
I don't think there's an easy solution right now. Because there isn't we typically just round our numbers to the nearest thousand or million, depending on the size of the business and the audience.
Aaron
MajorDomo @ Merit Medical
**Say "Thanks" by clicking the heart in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"0 -
Give this a try. You'll have to replace the inners with the fields from your database. I didn't build the code with optimization in mind, so you're welcome to tweak it as needed.
CONCAT(
CASE WHEN LENGTH(CONCAT('',ROUND(Sum(`SALES`), 0))) > 9
THEN
CONCAT('$',
CASE
WHEN LENGTH(CONCAT('',ROUND(Sum(`SALES`), 0))) = 12
THEN
CONCAT(
SUBSTRING(
CONCAT('',ROUND(Sum(`SALES`), 0)), 1, 3)
,',',
SUBSTRING(
CONCAT('',ROUND(Sum(`SALES`), 0)), 4, 3)
,',',
SUBSTRING(
CONCAT('',ROUND(Sum(`SALES`), 0)), 7, 3)
,',',
SUBSTRING(
CONCAT('',ROUND(Sum(`SALES`), 0)), 10, 3)
)
WHEN LENGTH(CONCAT('',ROUND(Sum(`SALES`), 0))) = 11
THEN
CONCAT(
SUBSTRING(
CONCAT('',ROUND(Sum(`SALES`), 0)), 1, 2)
,',',
SUBSTRING(
CONCAT('',ROUND(Sum(`SALES`), 0)), 3, 3)
,',',
SUBSTRING(
CONCAT('',ROUND(Sum(`SALES`), 0)), 6, 3)
,',',
SUBSTRING(
CONCAT('',ROUND(Sum(`SALES`), 0)), 9, 3)
)
WHEN LENGTH(CONCAT('',ROUND(Sum(`SALES`), 0))) = 10
THEN
CONCAT(
SUBSTRING(
CONCAT('',ROUND(Sum(`SALES`), 0)), 1, 1)
,',',
SUBSTRING(
CONCAT('',ROUND(Sum(`SALES`), 0)), 2, 3)
,',',
SUBSTRING(
CONCAT('',ROUND(Sum(`SALES`), 0)), 5, 3)
,',',
SUBSTRING(
CONCAT('',ROUND(Sum(`SALES`), 0)), 8, 3)
)
ELSE 'UNKNOWN'
END)
WHEN LENGTH(CONCAT('',ROUND(Sum(`SALES`), 0))) > 6
THEN
CONCAT('$',
CASE
WHEN LENGTH(CONCAT('',ROUND(Sum(`SALES`), 0))) = 9
THEN
CONCAT(
SUBSTRING(
CONCAT('',ROUND(Sum(`SALES`), 0)), 1, 3)
,',',
SUBSTRING(
CONCAT('',ROUND(Sum(`SALES`), 0)), 4, 3)
,',',
SUBSTRING(
CONCAT('',ROUND(Sum(`SALES`), 0)), 7, 3)
)
WHEN LENGTH(CONCAT('',ROUND(Sum(`SALES`), 0))) = 8
THEN
CONCAT(
SUBSTRING(
CONCAT('',ROUND(Sum(`SALES`), 0)), 1, 2)
,',',
SUBSTRING(
CONCAT('',ROUND(Sum(`SALES`), 0)), 3, 3)
,',',
SUBSTRING(
CONCAT('',ROUND(Sum(`SALES`), 0)), 6, 3)
)
WHEN LENGTH(CONCAT('',ROUND(Sum(`SALES`), 0))) = 7
THEN
CONCAT(
SUBSTRING(
CONCAT('',ROUND(Sum(`SALES`), 0)), 1, 1)
,',',
SUBSTRING(
CONCAT('',ROUND(Sum(`SALES`), 0)), 2, 3)
,',',
SUBSTRING(
CONCAT('',ROUND(Sum(`SALES`), 0)), 5, 3)
)
ELSE 'UNKNOWN'
END)
WHEN LENGTH(CONCAT('',ROUND(Sum(`SALES`), 0))) > 3
THEN
CONCAT('$',
CASE
WHEN LENGTH(CONCAT('',ROUND(Sum(`SALES`), 0))) = 6
THEN
CONCAT(
SUBSTRING(
CONCAT('',ROUND(Sum(`SALES`), 0)), 1, 3)
,',',
SUBSTRING(
CONCAT('',ROUND(Sum(`SALES`), 0)), 4, 3)
)
WHEN LENGTH(CONCAT('',ROUND(Sum(`SALES`), 0))) = 5
THEN
CONCAT(
SUBSTRING(
CONCAT('',ROUND(Sum(`SALES`), 0)), 1, 2)
,',',
SUBSTRING(
CONCAT('',ROUND(Sum(`SALES`), 0)), 3, 3)
)
WHEN LENGTH(CONCAT('',ROUND(Sum(`SALES`), 0))) = 4
THEN
CONCAT(
SUBSTRING(
CONCAT('',ROUND(Sum(`SALES`), 0)), 1, 1)
,',',
SUBSTRING(
CONCAT('',ROUND(Sum(`SALES`), 0)), 2, 3)
)
ELSE 'UNKNOWN'
END)
ELSE RIGHT(CONCAT('',ROUND(Sum(`SALES`), 0)),3)
END
,' || ',
CASE WHEN LENGTH(CONCAT('',ROUND(Sum(`PROFIT`), 0))) > 9
THEN
CONCAT('$',
CASE
WHEN LENGTH(CONCAT('',ROUND(Sum(`PROFIT`), 0))) = 12
THEN
CONCAT(
SUBSTRING(
CONCAT('',ROUND(Sum(`PROFIT`), 0)), 1, 3)
,',',
SUBSTRING(
CONCAT('',ROUND(Sum(`PROFIT`), 0)), 4, 3)
,',',
SUBSTRING(
CONCAT('',ROUND(Sum(`PROFIT`), 0)), 7, 3)
,',',
SUBSTRING(
CONCAT('',ROUND(Sum(`PROFIT`), 0)), 10, 3)
)
WHEN LENGTH(CONCAT('',ROUND(Sum(`PROFIT`), 0))) = 11
THEN
CONCAT(
SUBSTRING(
CONCAT('',ROUND(Sum(`PROFIT`), 0)), 1, 2)
,',',
SUBSTRING(
CONCAT('',ROUND(Sum(`PROFIT`), 0)), 3, 3)
,',',
SUBSTRING(
CONCAT('',ROUND(Sum(`PROFIT`), 0)), 6, 3)
,',',
SUBSTRING(
CONCAT('',ROUND(Sum(`PROFIT`), 0)), 9, 3)
)
WHEN LENGTH(CONCAT('',ROUND(Sum(`PROFIT`), 0))) = 10
THEN
CONCAT(
SUBSTRING(
CONCAT('',ROUND(Sum(`PROFIT`), 0)), 1, 1)
,',',
SUBSTRING(
CONCAT('',ROUND(Sum(`PROFIT`), 0)), 2, 3)
,',',
SUBSTRING(
CONCAT('',ROUND(Sum(`PROFIT`), 0)), 5, 3)
,',',
SUBSTRING(
CONCAT('',ROUND(Sum(`PROFIT`), 0)), 8, 3)
)
ELSE 'UNKNOWN'
END)
WHEN LENGTH(CONCAT('',ROUND(Sum(`PROFIT`), 0))) > 6
THEN
CONCAT('$',
CASE
WHEN LENGTH(CONCAT('',ROUND(Sum(`PROFIT`), 0))) = 9
THEN
CONCAT(
SUBSTRING(
CONCAT('',ROUND(Sum(`PROFIT`), 0)), 1, 3)
,',',
SUBSTRING(
CONCAT('',ROUND(Sum(`PROFIT`), 0)), 4, 3)
,',',
SUBSTRING(
CONCAT('',ROUND(Sum(`PROFIT`), 0)), 7, 3)
)
WHEN LENGTH(CONCAT('',ROUND(Sum(`PROFIT`), 0))) = 8
THEN
CONCAT(
SUBSTRING(
CONCAT('',ROUND(Sum(`PROFIT`), 0)), 1, 2)
,',',
SUBSTRING(
CONCAT('',ROUND(Sum(`PROFIT`), 0)), 3, 3)
,',',
SUBSTRING(
CONCAT('',ROUND(Sum(`PROFIT`), 0)), 6, 3)
)
WHEN LENGTH(CONCAT('',ROUND(Sum(`PROFIT`), 0))) = 7
THEN
CONCAT(
SUBSTRING(
CONCAT('',ROUND(Sum(`PROFIT`), 0)), 1, 1)
,',',
SUBSTRING(
CONCAT('',ROUND(Sum(`PROFIT`), 0)), 2, 3)
,',',
SUBSTRING(
CONCAT('',ROUND(Sum(`PROFIT`), 0)), 5, 3)
)
ELSE 'UNKNOWN'
END)
WHEN LENGTH(CONCAT('',ROUND(Sum(`PROFIT`), 0))) > 3
THEN
CONCAT('$',
CASE
WHEN LENGTH(CONCAT('',ROUND(Sum(`PROFIT`), 0))) = 6
THEN
CONCAT(
SUBSTRING(
CONCAT('',ROUND(Sum(`PROFIT`), 0)), 1, 3)
,',',
SUBSTRING(
CONCAT('',ROUND(Sum(`PROFIT`), 0)), 4, 3)
)
WHEN LENGTH(CONCAT('',ROUND(Sum(`PROFIT`), 0))) = 5
THEN
CONCAT(
SUBSTRING(
CONCAT('',ROUND(Sum(`PROFIT`), 0)), 1, 2)
,',',
SUBSTRING(
CONCAT('',ROUND(Sum(`PROFIT`), 0)), 3, 3)
)
WHEN LENGTH(CONCAT('',ROUND(Sum(`PROFIT`), 0))) = 4
THEN
CONCAT(
SUBSTRING(
CONCAT('',ROUND(Sum(`PROFIT`), 0)), 1, 1)
,',',
SUBSTRING(
CONCAT('',ROUND(Sum(`PROFIT`), 0)), 2, 3)
)
ELSE 'UNKNOWN'
END)
ELSE RIGHT(CONCAT('',ROUND(Sum(`PROFIT`), 0)),3)
END
)1 -
Marc_H, doesn't seem like it should be this challenging to do something as simple & routine as formatting a number string, but dang - you sure saved me with this! Our DOMO users are going to appreciate you proving a 'template' for this. Thank you sir!
0 -
Hi @Marc_H, i tried using the following code. I get error again and again whenever i am using Round and Sum functions. Without these i get the correct output but we need an aggregated sales number as the output for which i need to use Sum and Round functions.
can you help me out here.
Thank you
0
Categories
- All Categories
- 2K Product Ideas
- 2K Ideas Exchange
- 1.6K Connect
- 1.3K Connectors
- 311 Workbench
- 6 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
- 771 Automate
- 190 Apps
- 481 APIs & Domo Developer
- 77 Workflows
- 23 Code Engine
- 36 AI and Machine Learning
- 19 AI Chat
- AI Playground
- AI Projects and Models
- 17 Jupyter Workspaces
- 409 Distribute
- 120 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