Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hello,
I am developing a custom card, but I found that the numbers displayed on my card will omit the format of the original data, such as the percent sign and currency symbol, as shown in the picture below, the right side is my card, and the left side is my desired effect.
Since I want the data to be displayed in French format (in general, replace all periods with commas), I wrote the following code to convert the numbers:
But when I try this method, the utils in "powerbi.extensibility.utils" always report an error:
I'm sure I've imported everything I need, has there been a change in the method of reading the metadata format? After all, this video tutorial is three years ago. Is there any way to read the format of the metadata with the latest version of api?
Solved! Go to Solution.
Hi @Anonymous,
The metadata hasn't changed, but the powerbi-visuals-utils-formattingutils would have gone through a big change around the time this video was made (as they got moved to ES modules, which changes how they are imported).
The docs have an updated set of examples that you should be able to use in order to get the syntax you need to import and call the valueFormatter.
In short, you will need to create a formatter using the measure or column metadata's format property, e.g.:
If there is no format property, it will treat the format string as empty and just format it as a plain number.
If you want to auto-scale, you pass in the value parameter with the value of the number you wish to format. You can see examples of this in the linked doc under the thousand, million, billion and trillion examples. Formatting utils will apply the unit based on your locale. You can make this work as 'auto' (like core charts do) by passing in your measure value instead of a fixed value.
For percentages, as long as your format property contains a valid format string, this will work also. Alternatively, you can construct a format string manually in your code and pass this to the valueFormatter.
Regards,
Daniel
Proud to be a Super User!
On how to ask a technical question, if you really want an answer (courtesy of SQLBI)
Hi @Anonymous,
The metadata hasn't changed, but the powerbi-visuals-utils-formattingutils would have gone through a big change around the time this video was made (as they got moved to ES modules, which changes how they are imported).
The docs have an updated set of examples that you should be able to use in order to get the syntax you need to import and call the valueFormatter.
In short, you will need to create a formatter using the measure or column metadata's format property, e.g.:
If there is no format property, it will treat the format string as empty and just format it as a plain number.
If you want to auto-scale, you pass in the value parameter with the value of the number you wish to format. You can see examples of this in the linked doc under the thousand, million, billion and trillion examples. Formatting utils will apply the unit based on your locale. You can make this work as 'auto' (like core charts do) by passing in your measure value instead of a fixed value.
For percentages, as long as your format property contains a valid format string, this will work also. Alternatively, you can construct a format string manually in your code and pass this to the valueFormatter.
Regards,
Daniel
Proud to be a Super User!
On how to ask a technical question, if you really want an answer (courtesy of SQLBI)
Thanks! It works with the IValueFormatter.
@Anonymous play around with this if it works.
const locale = navigator.language;
const money = 100000;
new Intl.NumberFormat(locale,
{ style: 'currency', currency: 'USD', maximumFractionDigits: 0,notation: "compact" , compactDisplay: "short" }
).format(money);
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.