Culture.Current

Updated on

A Dynamic Value in the Power Query M language that returns the name of the current culture for the application. It can be used to adapt the application’s behavior to the cultural conventions of the user, such as date, number, and currency formatting. It’s key for applications targeting international audiences to ensure data is interpreted and displayed correctly for each user.

Examples

Let’s explore the practical application of the Culture.Current function in Power Query M language through a few tangible examples.Retrieving the culture code of your local machine is as simple as inputting Culture.Current without any additional opening and closing parentheses.

The culture code consists of a combination of language and country identifiers, ensuring precise alignment with cultural conventions. For instance, when I execute the function on my machine, it returns “en-US”. However, the output of this function will vary depending on the settings of your local machine.

Culture.Current // Output varies based on your local settings, e.g. "en-US"

Now, let’s say you’re developing an application targeting both American and Dutch audiences. You want to greet users in their local language when they launch your application. With the Culture.Current function, you can conditionally display messages in English or Dutch, depending on the user’s cultural setting:

if Culture.Current = "en-US" 
   then "Good morning" 
   else "Goeiemorgen"

Beyond custom messaging, Culture.Current can also be instrumental in formatting your queries dynamically, respecting the date, number, and currency formatting conventions of the user’s culture.

For example, if your application involves displaying date and time, you can use Culture.Current to ensure that the format aligns with the user’s preferences. An American user may prefer the format MM/DD/YYYY, while a Dutch user would be more accustomed to DD-MM-YYYY.

Date.FromText( "01-06-2023", "en-US" ) // Returns #date( 2023, 6, 1 )

Date.FromText( "01-06-2023", "nl-NL" ) // Returns #date( 2023, 1, 6 )

Date.FromText( "01-06-2023", Culture.Current ) // Output varies

The use of Culture.Current in Power Query M language extends even further when it comes to data normalization tasks, such as ensuring uniformity in a dataset sourced from different locales, or converting data into a format acceptable to an API that requires a specific locale setting.

Related dynamic values

Other related dynamic values are:

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/culture-current

2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy