Daily DAX : Day 426 USERCULTURE

Power BI DAX Function: USERCULTURE()

Description

The USERCULTURE() function returns the culture code (locale) of the current user as a string in the format "languagecode-country/regioncode", such as "en-US" for English (United States) or "de-DE" for German (Germany).

It has no parameters: USERCULTURE()

The locale is determined by:

  • Browser settings or operating system in Power BI Desktop.
  • User's language settings in the Power BI service (Settings > Language).

Use Cases

This function is primarily used for creating multilingual or localized reports in Power BI, especially in Premium workspaces. Common scenarios include:

  • Dynamic visual titles and labels: Translate titles based on the user's language.
  • Locale-specific formatting: Format dates, numbers, or text according to the user's culture.
  • Conditional logic for translations: Use with SWITCH to select translated text or values.

Examples

1. Dynamic Visual Title

Dynamic Title = SWITCH(
    USERCULTURE(),
    "en-US", "Sales by Product",
    "de-DE", "Umsatz nach Produkt",
    "fr-FR", "Ventes par produit",
    "es-ES", "Ventas por producto",
    "Sales by Product"  // Default
)

Use this measure for expression-based titles in visuals.

2. Locale-Specific Date Formatting

Today Localized = FORMAT(TODAY(), "dddd", USERCULTURE())

Outputs the day name in the user's language (e.g., "Tuesday" for en-US, "Dienstag" for de-DE).

3. Dynamic Currency Formatting (as text)

Sales Localized = SWITCH(
    USERCULTURE(),
    "en-US", FORMAT([Total Sales], "$#,##0.00"),
    "fr-FR", FORMAT([Total Sales], "#,##0.00 €"),
    FORMAT([Total Sales], "#,##0.00")  // Default
)

Note: USERCULTURE() works best in measures. In calculated columns/tables, it may return the model's default locale. Full support for dynamic behavior often requires Power BI Premium.


Comments

Popular posts from this blog

Daily DAX : Day 131 SELECTEDMEASURE

Daily DAX : Day 446 INFO.CSDLMETADATA

Daily DAX : Day 453 ENDOFWEEK