Charting

Charting

Textbox formatting using Concat

I am trying to do two things to my data displayed in a text box

 

1. Number formatting to include , thousand separator

2. Color format of a part of the text using <span> as recommended in another thread.

 

I could not find a clear solution for 1 and the solutions for 2 did not work (it just displayed the '<span style..."">','text','</span>' as is)

 

Thanks in advance. 

Welcome!

It looks like you're new here. Members get access to exclusive content, events, rewards, and more. Sign in or register to get started.
Sign In

Comments

  • Hi @user057613 

     

    #1 is possible with a lengthy beast mode.

    #2 is not possible. Text cards don't support HTML markup. Only within table cards.

     

    1. CONCAT(CASE WHEN LENGTH(ROUND(SUM(`Number Orders`), 0)) = 12 THEN
    2. CONCAT(
    3. SUBSTRING(ROUND(SUM(`Number Orders`), 0), 1, 3), ',',
    4. SUBSTRING(ROUND(SUM(`Number Orders`), 0), 4, 3), ',',
    5. SUBSTRING(ROUND(SUM(`Number Orders`), 0), 7, 3), ',',
    6. SUBSTRING(ROUND(SUM(`Number Orders`), 0), 10, 3)
    7. )
    8. WHEN LENGTH(ROUND(SUM(`Number Orders`), 0)) = 11 THEN
    9. CONCAT(
    10. SUBSTRING(ROUND(SUM(`Number Orders`), 0), 1, 2), ',',
    11. SUBSTRING(ROUND(SUM(`Number Orders`), 0), 3, 3), ',',
    12. SUBSTRING(ROUND(SUM(`Number Orders`), 0), 6, 3), ',',
    13. SUBSTRING(ROUND(SUM(`Number Orders`), 0), 9, 3)
    14. )
    15. WHEN LENGTH(ROUND(SUM(`Number Orders`), 0)) = 10 THEN
    16. CONCAT(
    17. SUBSTRING(ROUND(SUM(`Number Orders`), 0), 1, 1), ',',
    18. SUBSTRING(ROUND(SUM(`Number Orders`), 0), 2, 3), ',',
    19. SUBSTRING(ROUND(SUM(`Number Orders`), 0), 5, 3), ',',
    20. SUBSTRING(ROUND(SUM(`Number Orders`), 0), 8, 3)
    21. )
    22. WHEN LENGTH(ROUND(SUM(`Number Orders`), 0)) = 9 THEN
    23. CONCAT(
    24. SUBSTRING(ROUND(SUM(`Number Orders`), 0), 1, 3), ',',
    25. SUBSTRING(ROUND(SUM(`Number Orders`), 0), 4, 3), ',',
    26. SUBSTRING(ROUND(SUM(`Number Orders`), 0), 7, 3)
    27. )
    28. WHEN LENGTH(ROUND(SUM(`Number Orders`), 0)) = 8 THEN
    29. CONCAT(
    30. SUBSTRING(ROUND(SUM(`Number Orders`), 0), 1, 2), ',',
    31. SUBSTRING(ROUND(SUM(`Number Orders`), 0), 3, 3), ',',
    32. SUBSTRING(ROUND(SUM(`Number Orders`), 0), 6, 3)
    33. )
    34. WHEN LENGTH(ROUND(SUM(`Number Orders`), 0)) = 7 THEN
    35. CONCAT(
    36. SUBSTRING(ROUND(SUM(`Number Orders`), 0), 1, 1), ',',
    37. SUBSTRING(ROUND(SUM(`Number Orders`), 0), 2, 3), ',',
    38. SUBSTRING(ROUND(SUM(`Number Orders`), 0), 5, 3)
    39. )
    40. WHEN LENGTH(ROUND(SUM(`Number Orders`), 0)) = 6 THEN
    41. CONCAT(
    42. SUBSTRING(ROUND(SUM(`Number Orders`), 0), 1, 3), ',',
    43. SUBSTRING(ROUND(SUM(`Number Orders`), 0), 4, 3)
    44. )
    45. WHEN LENGTH(ROUND(SUM(`Number Orders`), 0)) = 5 THEN
    46. CONCAT(
    47. SUBSTRING(ROUND(SUM(`Number Orders`), 0), 1, 2), ',',
    48. SUBSTRING(ROUND(SUM(`Number Orders`), 0), 3, 3)
    49. )
    50. WHEN LENGTH(ROUND(SUM(`Number Orders`), 0)) = 4 THEN
    51. CONCAT(
    52. SUBSTRING(ROUND(SUM(`Number Orders`), 0), 1, 1), ',',
    53. SUBSTRING(ROUND(SUM(`Number Orders`), 0), 2, 3)
    54. )
    55. WHEN LENGTH(ROUND(SUM(`Number Orders`), 0)) <= 3 THEN
    56. ROUND(SUM(`Number Orders`), 0)
    57. WHEN SUM(`Number Orders`) IS NULL THEN 0
    58. ELSE ''
    59. END)

     

    For good measure here's a version with abbreviated numbers

    1. CONCAT(CASE WHEN LENGTH(ROUND(SUM(`Number Orders`), 0)) = 10 THEN
    2. CONCAT(
    3. ROUND(SUM(`Number Orders`) / 1000000000, 2), 'B'
    4. )
    5. WHEN LENGTH(ROUND(SUM(`Number Orders`), 0)) >= 7 THEN
    6. CONCAT(
    7. ROUND(SUM(`Number Orders`) / 1000000, 2), 'M'
    8. )
    9. WHEN LENGTH(ROUND(SUM(`Number Orders`), 0)) >= 4 THEN
    10. CONCAT(
    11. ROUND(SUM(`Number Orders`) / 1000, 2), 'K'
    12. )
    13. WHEN LENGTH(ROUND(SUM(`Number Orders`), 0)) <= 3 THEN
    14. ROUND(SUM(`Number Orders`), 0)
    15. WHEN SUM(`Number Orders`) IS NULL THEN 0
    16. ELSE ''
    17. END
    18. )

     

    Just replace the `Number Orders` fields with your own.

    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**
  • Thank you @GrantSmith ?

     

    Yes, that is what I was looking for! ?

    However, when I try to use that new beast mode in the table, it does not show a SUM option as it recognizes it as a text field. How do I get it to calculate as a numeric field and then just display with the "M"?

     

    Thanks, Angela

  • The abbreviated beast mode is doing the SUM already for you and adding in the M (if it's in millions). Because it's adding in the extra "M" it's treating the resulting data type as a string. You shouldn't need to select the SUM aggregation from the column as it's done inside the beast mode.

    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**
This discussion has been closed.