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 li...
- 9 years ago
abhay03
9 years agoHelper I
Anonymous,
Did you managed to get the formatting in your visual, I am in the exact same situation.
I am using the valueFormatter but receiving error "Cannot read property 'valueFormatter' of undefined" in console even for the examples here.
Anonymous
9 years agoNot 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!
- satishr8 years agoHelper III
Anonymous I implemented your code and it works. However, the formatting doesn't change once the visual is displayed. For example, I have a number formatted as a decimal number with 3 decimal places. My custom visual shows this value correctly when I use it. But if I change the format to Percentage in the Modelling menu, it doesn't reflect. Did you face the same issue?