Forum Discussion
Anonymous
9 years agoNot applicable
Number Formatting Function
In my custom visual, I'm trying to get the format from a measure. This passes the format of the measure to the ts file:
dataViews[0].categorical.values[0].source.format
It produces a value like: '0.0 %;-0.0 %;0.0 %' for a percent with 1 decimal and '\$#,0;(\$#,0);\$#,0' for a dollar amount.
My question is, how do I apply that to a number? There has to be a standard function, right?
Thanks
7 Replies
- v-chuncz-msftCommunity Support
- AnonymousNot applicable
I did get it working. This is an example of how I used it:
import valueFormatter = powerbi.extensibility.utils.formatting.valueFormatter; kpiNumber = valueFormatter.create({ format: categorical.values[kpiRef].source.format, value: 1001, precision: settings.kpi.decimalPlaces }); kpiNumber.format(kpi)Good luck!