Summary Number with 2 metrics needing commas and rounding
Hi,
I am trying to make a Summary Number for a card with a calculated field that will look like this:
1,121 Loans | $211,100,123
or even better, if possible:
1,121 Loans | $211.1M
The first number could be anywhere from 5 to 500,000. The second currency number could be anywhere from $10,000 to $1 Billion dollars.
My current formula is:
Concat(COUNT(`LoanAmount`), ' Loans | $',
Round(SUM(`LoanAmount`),0))
The result looks like this:
1121 Loans | $211100123
How can I get the desired format in there?
Thanks in advance
Best Answer
-
Hi @AJ2020
Since Domo doesn't support formatting strings yet you'll need to do it manually. You can utilize a beastmode with CONCAT and a bunch of substring manipulation like this to solve it (this is up to 12 digits / Billions but can be modified to go higher)
(Untested but should give you the general framework)
CONCAT(CASE WHEN LENGTH(ROUND(SUM(`Amount`), 0)) = 12 THEN
CONCAT(
SUBSTRING(ROUND(SUM(`Amount`), 0), 1, 3), ',',
SUBSTRING(ROUND(SUM(`Amount`), 0), 4, 3), ',',
SUBSTRING(ROUND(SUM(`Amount`), 0), 7, 3), ',',
SUBSTRING(ROUND(SUM(`Amount`), 0), 10, 3)
)
WHEN LENGTH(ROUND(SUM(`Amount`), 0)) = 11 THEN
CONCAT(
SUBSTRING(ROUND(SUM(`Amount`), 0), 1, 2), ',',
SUBSTRING(ROUND(SUM(`Amount`), 0), 3, 3), ',',
SUBSTRING(ROUND(SUM(`Amount`), 0), 6, 3), ',',
SUBSTRING(ROUND(SUM(`Amount`), 0), 9, 3)
)
WHEN LENGTH(ROUND(SUM(`Amount`), 0)) = 10 THEN
CONCAT(
SUBSTRING(ROUND(SUM(`Amount`), 0), 1, 1), ',',
SUBSTRING(ROUND(SUM(`Amount`), 0), 2, 3), ',',
SUBSTRING(ROUND(SUM(`Amount`), 0), 5, 3), ',',
SUBSTRING(ROUND(SUM(`Amount`), 0), 8, 3)
)
WHEN LENGTH(ROUND(SUM(`Amount`), 0)) = 9 THEN
CONCAT(
SUBSTRING(ROUND(SUM(`Amount`), 0), 1, 3), ',',
SUBSTRING(ROUND(SUM(`Amount`), 0), 4, 3), ',',
SUBSTRING(ROUND(SUM(`Amount`), 0), 7, 3)
)
WHEN LENGTH(ROUND(SUM(`Amount`), 0)) = 8 THEN
CONCAT(
SUBSTRING(ROUND(SUM(`Amount`), 0), 1, 2), ',',
SUBSTRING(ROUND(SUM(`Amount`), 0), 3, 3), ',',
SUBSTRING(ROUND(SUM(`Amount`), 0), 6, 3)
)
WHEN LENGTH(ROUND(SUM(`Amount`), 0)) = 7 THEN
CONCAT(
SUBSTRING(ROUND(SUM(`Amount`), 0), 1, 1), ',',
SUBSTRING(ROUND(SUM(`Amount`), 0), 2, 3), ',',
SUBSTRING(ROUND(SUM(`Amount`), 0), 5, 3)
)
WHEN LENGTH(ROUND(SUM(`Amount`), 0)) = 6 THEN
CONCAT(
SUBSTRING(ROUND(SUM(`Amount`), 0), 1, 3), ',',
SUBSTRING(ROUND(SUM(`Amount`), 0), 4, 3)
)
WHEN LENGTH(ROUND(SUM(`Amount`), 0)) = 5 THEN
CONCAT(
SUBSTRING(ROUND(SUM(`Amount`), 0), 1, 2), ',',
SUBSTRING(ROUND(SUM(`Amount`), 0), 3, 3)
)
WHEN LENGTH(ROUND(SUM(`Amount`), 0)) = 4 THEN
CONCAT(
SUBSTRING(ROUND(SUM(`Amount`), 0), 1, 1), ',',
SUBSTRING(ROUND(SUM(`Amount`), 0), 2, 3)
)
WHEN LENGTH(ROUND(SUM(`Amount`), 0)) <= 3 THEN
ROUND(SUM(`Amount`), 0)
WHEN SUM(`Amount`) IS NULL THEN 0
ELSE ''
END
, 'Loans | $'
, CASE WHEN LENGTH(ROUND(SUM(`Revenue`), 0)) = 12 THEN
CONCAT(
SUBSTRING(ROUND(SUM(`Revenue`), 0), 1, 3), ',',
SUBSTRING(ROUND(SUM(`Revenue`), 0), 4, 3), ',',
SUBSTRING(ROUND(SUM(`Revenue`), 0), 7, 3), ',',
SUBSTRING(ROUND(SUM(`Revenue`), 0), 10, 3)
)
WHEN LENGTH(ROUND(SUM(`Revenue`), 0)) = 11 THEN
CONCAT(
SUBSTRING(ROUND(SUM(`Revenue`), 0), 1, 2), ',',
SUBSTRING(ROUND(SUM(`Revenue`), 0), 3, 3), ',',
SUBSTRING(ROUND(SUM(`Revenue`), 0), 6, 3), ',',
SUBSTRING(ROUND(SUM(`Revenue`), 0), 9, 3)
)
WHEN LENGTH(ROUND(SUM(`Revenue`), 0)) = 10 THEN
CONCAT(
SUBSTRING(ROUND(SUM(`Revenue`), 0), 1, 1), ',',
SUBSTRING(ROUND(SUM(`Revenue`), 0), 2, 3), ',',
SUBSTRING(ROUND(SUM(`Revenue`), 0), 5, 3), ',',
SUBSTRING(ROUND(SUM(`Revenue`), 0), 7, 3)
)
WHEN LENGTH(ROUND(SUM(`Revenue`), 0)) = 9 THEN
CONCAT(
SUBSTRING(ROUND(SUM(`Revenue`), 0), 1, 3), ',',
SUBSTRING(ROUND(SUM(`Revenue`), 0), 4, 3), ',',
SUBSTRING(ROUND(SUM(`Revenue`), 0), 7, 3)
)
WHEN LENGTH(ROUND(SUM(`Revenue`), 0)) = 8 THEN
CONCAT(
SUBSTRING(ROUND(SUM(`Revenue`), 0), 1, 2), ',',
SUBSTRING(ROUND(SUM(`Revenue`), 0), 3, 3), ',',
SUBSTRING(ROUND(SUM(`Revenue`), 0), 6, 3)
)
WHEN LENGTH(ROUND(SUM(`Revenue`), 0)) = 7 THEN
CONCAT(
SUBSTRING(ROUND(SUM(`Revenue`), 0), 1, 1), ',',
SUBSTRING(ROUND(SUM(`Revenue`), 0), 2, 3), ',',
SUBSTRING(ROUND(SUM(`Revenue`), 0), 5, 3)
)
WHEN LENGTH(ROUND(SUM(`Revenue`), 0)) = 6 THEN
CONCAT(
SUBSTRING(ROUND(SUM(`Revenue`), 0), 1, 3), ',',
SUBSTRING(ROUND(SUM(`Revenue`), 0), 4, 3)
)
WHEN LENGTH(ROUND(SUM(`Revenue`), 0)) = 5 THEN
CONCAT(
SUBSTRING(ROUND(SUM(`Revenue`), 0), 1, 2), ',',
SUBSTRING(ROUND(SUM(`Revenue`), 0), 3, 3)
)
WHEN LENGTH(ROUND(SUM(`Revenue`), 0)) = 4 THEN
CONCAT(
SUBSTRING(ROUND(SUM(`Revenue`), 0), 1, 1), ',',
SUBSTRING(ROUND(SUM(`Revenue`), 0), 2, 3)
)
WHEN LENGTH(ROUND(SUM(`Revenue`), 0)) <= 3 THEN
ROUND(SUM(`Revenue`), 0)
WHEN SUM(`Revenue`) IS NULL THEN 0
ELSE 'ERROR'
END
)**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**1
Answers
-
Hi @AJ2020
Since Domo doesn't support formatting strings yet you'll need to do it manually. You can utilize a beastmode with CONCAT and a bunch of substring manipulation like this to solve it (this is up to 12 digits / Billions but can be modified to go higher)
(Untested but should give you the general framework)
CONCAT(CASE WHEN LENGTH(ROUND(SUM(`Amount`), 0)) = 12 THEN
CONCAT(
SUBSTRING(ROUND(SUM(`Amount`), 0), 1, 3), ',',
SUBSTRING(ROUND(SUM(`Amount`), 0), 4, 3), ',',
SUBSTRING(ROUND(SUM(`Amount`), 0), 7, 3), ',',
SUBSTRING(ROUND(SUM(`Amount`), 0), 10, 3)
)
WHEN LENGTH(ROUND(SUM(`Amount`), 0)) = 11 THEN
CONCAT(
SUBSTRING(ROUND(SUM(`Amount`), 0), 1, 2), ',',
SUBSTRING(ROUND(SUM(`Amount`), 0), 3, 3), ',',
SUBSTRING(ROUND(SUM(`Amount`), 0), 6, 3), ',',
SUBSTRING(ROUND(SUM(`Amount`), 0), 9, 3)
)
WHEN LENGTH(ROUND(SUM(`Amount`), 0)) = 10 THEN
CONCAT(
SUBSTRING(ROUND(SUM(`Amount`), 0), 1, 1), ',',
SUBSTRING(ROUND(SUM(`Amount`), 0), 2, 3), ',',
SUBSTRING(ROUND(SUM(`Amount`), 0), 5, 3), ',',
SUBSTRING(ROUND(SUM(`Amount`), 0), 8, 3)
)
WHEN LENGTH(ROUND(SUM(`Amount`), 0)) = 9 THEN
CONCAT(
SUBSTRING(ROUND(SUM(`Amount`), 0), 1, 3), ',',
SUBSTRING(ROUND(SUM(`Amount`), 0), 4, 3), ',',
SUBSTRING(ROUND(SUM(`Amount`), 0), 7, 3)
)
WHEN LENGTH(ROUND(SUM(`Amount`), 0)) = 8 THEN
CONCAT(
SUBSTRING(ROUND(SUM(`Amount`), 0), 1, 2), ',',
SUBSTRING(ROUND(SUM(`Amount`), 0), 3, 3), ',',
SUBSTRING(ROUND(SUM(`Amount`), 0), 6, 3)
)
WHEN LENGTH(ROUND(SUM(`Amount`), 0)) = 7 THEN
CONCAT(
SUBSTRING(ROUND(SUM(`Amount`), 0), 1, 1), ',',
SUBSTRING(ROUND(SUM(`Amount`), 0), 2, 3), ',',
SUBSTRING(ROUND(SUM(`Amount`), 0), 5, 3)
)
WHEN LENGTH(ROUND(SUM(`Amount`), 0)) = 6 THEN
CONCAT(
SUBSTRING(ROUND(SUM(`Amount`), 0), 1, 3), ',',
SUBSTRING(ROUND(SUM(`Amount`), 0), 4, 3)
)
WHEN LENGTH(ROUND(SUM(`Amount`), 0)) = 5 THEN
CONCAT(
SUBSTRING(ROUND(SUM(`Amount`), 0), 1, 2), ',',
SUBSTRING(ROUND(SUM(`Amount`), 0), 3, 3)
)
WHEN LENGTH(ROUND(SUM(`Amount`), 0)) = 4 THEN
CONCAT(
SUBSTRING(ROUND(SUM(`Amount`), 0), 1, 1), ',',
SUBSTRING(ROUND(SUM(`Amount`), 0), 2, 3)
)
WHEN LENGTH(ROUND(SUM(`Amount`), 0)) <= 3 THEN
ROUND(SUM(`Amount`), 0)
WHEN SUM(`Amount`) IS NULL THEN 0
ELSE ''
END
, 'Loans | $'
, CASE WHEN LENGTH(ROUND(SUM(`Revenue`), 0)) = 12 THEN
CONCAT(
SUBSTRING(ROUND(SUM(`Revenue`), 0), 1, 3), ',',
SUBSTRING(ROUND(SUM(`Revenue`), 0), 4, 3), ',',
SUBSTRING(ROUND(SUM(`Revenue`), 0), 7, 3), ',',
SUBSTRING(ROUND(SUM(`Revenue`), 0), 10, 3)
)
WHEN LENGTH(ROUND(SUM(`Revenue`), 0)) = 11 THEN
CONCAT(
SUBSTRING(ROUND(SUM(`Revenue`), 0), 1, 2), ',',
SUBSTRING(ROUND(SUM(`Revenue`), 0), 3, 3), ',',
SUBSTRING(ROUND(SUM(`Revenue`), 0), 6, 3), ',',
SUBSTRING(ROUND(SUM(`Revenue`), 0), 9, 3)
)
WHEN LENGTH(ROUND(SUM(`Revenue`), 0)) = 10 THEN
CONCAT(
SUBSTRING(ROUND(SUM(`Revenue`), 0), 1, 1), ',',
SUBSTRING(ROUND(SUM(`Revenue`), 0), 2, 3), ',',
SUBSTRING(ROUND(SUM(`Revenue`), 0), 5, 3), ',',
SUBSTRING(ROUND(SUM(`Revenue`), 0), 7, 3)
)
WHEN LENGTH(ROUND(SUM(`Revenue`), 0)) = 9 THEN
CONCAT(
SUBSTRING(ROUND(SUM(`Revenue`), 0), 1, 3), ',',
SUBSTRING(ROUND(SUM(`Revenue`), 0), 4, 3), ',',
SUBSTRING(ROUND(SUM(`Revenue`), 0), 7, 3)
)
WHEN LENGTH(ROUND(SUM(`Revenue`), 0)) = 8 THEN
CONCAT(
SUBSTRING(ROUND(SUM(`Revenue`), 0), 1, 2), ',',
SUBSTRING(ROUND(SUM(`Revenue`), 0), 3, 3), ',',
SUBSTRING(ROUND(SUM(`Revenue`), 0), 6, 3)
)
WHEN LENGTH(ROUND(SUM(`Revenue`), 0)) = 7 THEN
CONCAT(
SUBSTRING(ROUND(SUM(`Revenue`), 0), 1, 1), ',',
SUBSTRING(ROUND(SUM(`Revenue`), 0), 2, 3), ',',
SUBSTRING(ROUND(SUM(`Revenue`), 0), 5, 3)
)
WHEN LENGTH(ROUND(SUM(`Revenue`), 0)) = 6 THEN
CONCAT(
SUBSTRING(ROUND(SUM(`Revenue`), 0), 1, 3), ',',
SUBSTRING(ROUND(SUM(`Revenue`), 0), 4, 3)
)
WHEN LENGTH(ROUND(SUM(`Revenue`), 0)) = 5 THEN
CONCAT(
SUBSTRING(ROUND(SUM(`Revenue`), 0), 1, 2), ',',
SUBSTRING(ROUND(SUM(`Revenue`), 0), 3, 3)
)
WHEN LENGTH(ROUND(SUM(`Revenue`), 0)) = 4 THEN
CONCAT(
SUBSTRING(ROUND(SUM(`Revenue`), 0), 1, 1), ',',
SUBSTRING(ROUND(SUM(`Revenue`), 0), 2, 3)
)
WHEN LENGTH(ROUND(SUM(`Revenue`), 0)) <= 3 THEN
ROUND(SUM(`Revenue`), 0)
WHEN SUM(`Revenue`) IS NULL THEN 0
ELSE 'ERROR'
END
)**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**1
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 616 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 738 Beast Mode
- 58 App Studio
- 40 Variables
- 685 Automate
- 176 Apps
- 452 APIs & Domo Developer
- 47 Workflows
- 10 DomoAI
- 36 Predict
- 15 Jupyter Workspaces
- 21 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 124 Manage
- 121 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 108 Community Announcements
- 4.8K Archive