Power Query: Appearing Cultured
31 October 2018
Welcome to our Power Query blog. This week, I look at how M and culture can go together.
In previous blogs, the M functions I have used have included a culture parameter. For example, in Power Query: Birthday Lists, I used the following function:
Number.From(value as any, optional culture as nullable text) as nullable number
I was converting a date to its numerical equivalent in order to create a list. I took the default local culture, but I’d like to know the other options open to me. I am going to try this with another culture to see what happens. I have a large choice of cultures. The following information comes from the Microsoft help pages:
1 When you specify es-MX or es-US in the request, the culture is converted to es-ES.
2 When you specify fr-CA in the request, the culture is converted to fr-FR.
In my blog, I wanted to convert a date to a number:
= Number.From(#date(2017,11,15))
I try with another culture.
In this case, I get the same answer – however, there are many M functions that can use culture, as the following list shows:
Byte.From
Comparer.FromCulture
Currency.From
Date.DayOfWeekName
Date.From
Date.FromText
Date.MonthName
Date.ToText
DateTime.From
DateTime.FromText
DateTime.ToText
DateTimeZone.From
DateTimeZone.FromText
DateTimeZone.ToText
Decimal.From
Double.From
Int16.From
Int32.From
Int64.From
Int8.From
Number.From
Number.FromText
Number.ToText
Percentage.From
Single.From
Table.TransformColumnTypes
Text.Format
Text.From
Text.Lower
Text.Proper
Text.Upper
Time.From
Time.FromText
Time.ToText
Value.FromText
So, I’ll try looking at the function Date.DayofWeekName:
Date.DayOfWeekName(date as any, optional culture as nullable text)
Firstly, with my local culture:
So far, so good. If I change the culture to Chinese I get
And in Urdu…
Much more satisfying results! Of course, this does leave the question of how I know the local culture that Power Query is using:
The M function
Culture.Current
will tell me my current setting.
Come back next time for more ways to use Power Query!