microsoft / microsoft/powerbi-visuals-utils-formattingutils
Formatting zeroes with unit abbreviation always returns a format with the highest unit abbreviation
Open
@uve is already working on this.
Since Oct 8, 2020.
bug
- Dominant language
- TypeScript
- Stars
- 27
- Forks
- 38
- Avg merge
- 20h 37m
- Merged PRs (30d)
- 1
Description
I want to format the value of a custom card, and the code is as follows:
let formatter = valueFormatter.create({
format: "#,#0 €;(#,#0 €);#,#0 €",
cultureSelector: 'it-IT',
formatSingleValues: true,
value: 1e9
});
let formattedValue = formatter.format(value);
The results are great when value is a non-zero number, but it shows 0bn€ when zero.
Setting value as a very low number (like 0.00000001) shows the correct 0 € format.
Since I'm using formatSingleValue: true i expect 0 to be formatted without any unit abbreviation.
Tests I've done:
formatSingleValues: true | value 10000000 | 10M€ | OK
formatSingleValues: false | value 10000000 | 0,01bn€ | OK
formatSingleValues: true | value 0.000001 | 0€ | OK
formatSingleValues: false | value 0.000001 | 0bn€ | OK
formatSingleValues: true | value 0 | 0bn€ | ERROR
formatSingleValues: false | value 0 | 0bn€ | OK
Everything was tested on 4.7.0 and 4.6.0.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.