concat() integers
Is there a way in beastmode to CONCAT() a number with anything and not lose its thousands separator?
In my beastmode, accounts_sending_campaigns_distinct
and sum(`reach`) are both integers that I wanted to be displayed with thousand separators
CONCAT('
<div style="font-size:15px; color:#EDEDDA;"> <div> <span style="font-size:20px; color:#EDEDDA"><b>',
`accounts_sending_campaigns_distinct`,
'</b></span>
Partners Sending Campaigns </div> <div>
<span style="font-size:20px; color:#EDEDDA"><b>',
SUM(`reach`),
'</b></span> Reach<b> </div>
</div>
')
I tried TO_CHAR(SUM(`reach`), '9,999.99') but I don't think TO_CHAR is recognized in beastmode
Best Answer
-
So this answer makes use of a Beast Mode provided by @JacobFolsom from 2018. Thanks Jacob!
This answer is set up for a max of 9 digits. You can modify it if you need to handle more than that.
An example below. Value shows the base value, formatted with commas as Domo automatically does. The next column shows the CONCAT() label, where we can see the formatting is removed. The last column shows the CONCAT() label, but using a formatting beast mode.
Value Formatted is achieved using the below beast mode from Jacob.
CONCAT('Label: ',CASE
WHEN LENGTH(ROUND(SUM(Column))) = 9 -- 9 digits = hundreds of millions
THEN
CONCAT(
SUBSTRING(ROUND(SUM(Column)),1,3), -- first comma block
',',
SUBSTRING(ROUND(SUM(Column)), 3,3), -- second comma block
',',
SUBSTRING(ROUND(SUM(Column)),6,3) -- third comma block
)
WHEN LENGTH(ROUND(SUM(Column))) = 8 -- 8 digits = tens of millions
THEN
CONCAT(
SUBSTRING(ROUND(SUM(Column)),1,2), -- first comma block
',',
SUBSTRING(ROUND(SUM(Column)), 2,3), -- second comma block
',',
SUBSTRING(ROUND(SUM(Column)),6,3) -- third comma block
)
WHEN LENGTH(ROUND(SUM(Column))) = 7 -- 7 digits = millions
THEN
CONCAT(
SUBSTRING(ROUND(SUM(Column)),1,1), -- first comma block
',',
SUBSTRING(ROUND(SUM(Column)), 2,3), -- second comma block
',',
SUBSTRING(ROUND(SUM(Column)),5,3) -- third comma block
)
WHEN LENGTH(ROUND(SUM(Column))) = 6 -- 6 digits = hundreds of thousands
THEN
CONCAT(
SUBSTRING(ROUND(SUM(Column)),1,3), -- first comma block
',',
SUBSTRING(ROUND(SUM(Column)), 4,3) -- second comma block
)
WHEN LENGTH(ROUND(SUM(Column))) = 5 -- 5 digits = tens of thousands
THEN
CONCAT(
SUBSTRING(ROUND(SUM(Column)),1,2), -- first comma block
',',
SUBSTRING(ROUND(SUM(Column)), 3,3) -- second comma block
)
WHEN LENGTH(ROUND(SUM(Column))) = 4 -- 4 digits = thousands
THEN
CONCAT(
SUBSTRING(ROUND(SUM(Column)),1,1), -- first comma block
',',
SUBSTRING(ROUND(SUM(Column)), 2,3) -- second comma block
)
WHEN LENGTH(ROUND(SUM(Column))) < 4 -- < 4 digits = hundreds or less
THEN ROUND(SUM(Column))
END)Another option would be to divide your output value, and then format those abbreviated values. I.e. - instead of 100,000 | 100k, or 1,000,000 = 1,000K or 1M. That would require a different beast mode though.
David Cunningham
** Was this post helpful? Click Agree 😀, Like 👍️, or Awesome ❤️ below **
** Did this solve your problem? Accept it as a solution! ✔️**2
Answers
-
The short answer to the best of my knowledge is that concat() removes formatting.
However, with that being said I believe there is a way to achieve this with some logic in the beast mode based around the length of the output. Or with division and rounding. I’ll update tomorrow morning with some more specific examples once I’ve had a chance to play around with it.
David Cunningham
** Was this post helpful? Click Agree 😀, Like 👍️, or Awesome ❤️ below **
** Did this solve your problem? Accept it as a solution! ✔️**0 -
So this answer makes use of a Beast Mode provided by @JacobFolsom from 2018. Thanks Jacob!
This answer is set up for a max of 9 digits. You can modify it if you need to handle more than that.
An example below. Value shows the base value, formatted with commas as Domo automatically does. The next column shows the CONCAT() label, where we can see the formatting is removed. The last column shows the CONCAT() label, but using a formatting beast mode.
Value Formatted is achieved using the below beast mode from Jacob.
CONCAT('Label: ',CASE
WHEN LENGTH(ROUND(SUM(Column))) = 9 -- 9 digits = hundreds of millions
THEN
CONCAT(
SUBSTRING(ROUND(SUM(Column)),1,3), -- first comma block
',',
SUBSTRING(ROUND(SUM(Column)), 3,3), -- second comma block
',',
SUBSTRING(ROUND(SUM(Column)),6,3) -- third comma block
)
WHEN LENGTH(ROUND(SUM(Column))) = 8 -- 8 digits = tens of millions
THEN
CONCAT(
SUBSTRING(ROUND(SUM(Column)),1,2), -- first comma block
',',
SUBSTRING(ROUND(SUM(Column)), 2,3), -- second comma block
',',
SUBSTRING(ROUND(SUM(Column)),6,3) -- third comma block
)
WHEN LENGTH(ROUND(SUM(Column))) = 7 -- 7 digits = millions
THEN
CONCAT(
SUBSTRING(ROUND(SUM(Column)),1,1), -- first comma block
',',
SUBSTRING(ROUND(SUM(Column)), 2,3), -- second comma block
',',
SUBSTRING(ROUND(SUM(Column)),5,3) -- third comma block
)
WHEN LENGTH(ROUND(SUM(Column))) = 6 -- 6 digits = hundreds of thousands
THEN
CONCAT(
SUBSTRING(ROUND(SUM(Column)),1,3), -- first comma block
',',
SUBSTRING(ROUND(SUM(Column)), 4,3) -- second comma block
)
WHEN LENGTH(ROUND(SUM(Column))) = 5 -- 5 digits = tens of thousands
THEN
CONCAT(
SUBSTRING(ROUND(SUM(Column)),1,2), -- first comma block
',',
SUBSTRING(ROUND(SUM(Column)), 3,3) -- second comma block
)
WHEN LENGTH(ROUND(SUM(Column))) = 4 -- 4 digits = thousands
THEN
CONCAT(
SUBSTRING(ROUND(SUM(Column)),1,1), -- first comma block
',',
SUBSTRING(ROUND(SUM(Column)), 2,3) -- second comma block
)
WHEN LENGTH(ROUND(SUM(Column))) < 4 -- < 4 digits = hundreds or less
THEN ROUND(SUM(Column))
END)Another option would be to divide your output value, and then format those abbreviated values. I.e. - instead of 100,000 | 100k, or 1,000,000 = 1,000K or 1M. That would require a different beast mode though.
David Cunningham
** Was this post helpful? Click Agree 😀, Like 👍️, or Awesome ❤️ below **
** Did this solve your problem? Accept it as a solution! ✔️**2 -
@david_cunningham it works, this is clever. Thanks for your help.
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
- 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