Hi, we are trying to format measures using some te...
# gooddata-ui
Hi, we are trying to format measures using some templates. Is there any helper function we can use?
Hi Prashant! If I understand correctly, you would like to format the output of a measure (=metric) based on some criteria, as mentioned here. Metric formatting is usually done on the back end and itself is a property of a particular metric. A ValueFormatter type is also a part of the UI SDK. An example would be to format the measure output to truncate large numbers. In that case, the value of the
would be as follows:
Copy code
[>=1000000000]$#,,,.0 B;[>=1000000]$#,,.0 M;[>=1000]$#,.0 K;[>=0]$#,##0;[<=-1000000000]-$#,,,.0 B;[<=-1000000]-$#,,.0 M;[<=-1000]-$#,.0 K;[<0]-$#,##0
Please let me know if this is what you are looking for. Thank you!
@Marek Horvat, wondering if we can use
or anything we can use where we can send the format as input.
we need to format the measure values on the go. Have to do the same at the front end. Please provide the alternatives.
@Prashant Sharma you can definitely go ahead and use
to format numbers on the go. It utilizes this package for formatting.
I have installed @gooddata/numberjs library in React application and using
function. It seems working fine. Thanks for the help.
🙌 1