Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
wolfgang2
Frequent Visitor

ValueFormatter ignoring culture

I have an issue with valueFormatter where it ignores the specified culture and always defaults to "en-US":

import { valueFormatter } from "powerbi-visuals-utils-formattingutils";
...
formatter = valueFormatter.create({ value: 1000, precision: 1, cultureSelector: "de-DE" });
formattedValue = formatter.format(3400);

This results in 3.4K instead of 3,4 Tsd.
1 ACCEPTED SOLUTION

If the separator/decimal symbols are right after making the changes, it's probably "working." Unfortunately, I'm not best placed to determine how far it goes for the units, as English is my first language. During testing, I have only really confirmed the units match what *I* might expect (although I have a rudimentary understanding of which separators are needed for various locales). It is known that there are some cases where, even if all locales are bundled, Power BI doesn't provide the correct locale to the visual host (e.g., Swiss German, or de-CH), but it does supply de-DE correctly.

 

MS uses the Globalize library to handle localization in powerbi-visuals-utils-formatingutils, and from a cursory look, I think the unit handling is not culture-specific. If you want a definitive answer, your best bet would be to check directly with MS (pbicvsupport@microsoft.com).

 

All the best,

 

Daniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




View solution in original post

3 REPLIES 3
wolfgang2
Frequent Visitor

Hello, @dm-p 
Your suggestions fixed the issue but only partially. With the locales included, the valueFormatter is giving the correct thousands separator and decimal symbols based on the current locale. However, the units for thousand, million, billion (K, M, bn etc.) are not correct. Is this even supported? I decided to include specific locales. Thanks for the help anyway!

If the separator/decimal symbols are right after making the changes, it's probably "working." Unfortunately, I'm not best placed to determine how far it goes for the units, as English is my first language. During testing, I have only really confirmed the units match what *I* might expect (although I have a rudimentary understanding of which separators are needed for various locales). It is known that there are some cases where, even if all locales are bundled, Power BI doesn't provide the correct locale to the visual host (e.g., Swiss German, or de-CH), but it does supply de-DE correctly.

 

MS uses the Globalize library to handle localization in powerbi-visuals-utils-formatingutils, and from a cursory look, I think the unit handling is not culture-specific. If you want a definitive answer, your best bet would be to check directly with MS (pbicvsupport@microsoft.com).

 

All the best,

 

Daniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




dm-p
Super User
Super User

Hi @wolfgang2,

 

Are you specifying --all-locales (or bundling de-DE) when running developer mode or packaging your visual? Recently, the tools omit locales due to their size when packaging and you must specify which to include. You can manually specify locales to include by adding an empty stringResources file for your desired languages, as detailed here. Personally, I run my dev and package commands with --all-locales, as despite the size, this provides the best overall support for global users if publishing to AppSource. If your visual is intended for a private audience, then it may be better just to add the locales you need.

 

Cheers,

 

Daniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.

Top Solution Authors