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.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
- 754 Beast Mode
- 61 App Studio
- 41 Variables
- 693 Automate
- 178 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