共用方式為


Text.From

語法

Text.From(value as any, optional culture as nullable text) as nullable text

關於

傳回指定值的文字表示。

  • value:要轉換成文字的值。 此值可以是 numberdatetimedatetimedatetimezonelogicaldurationbinary 值。 如果指定的值為 null,則此函式會傳 null回 。
  • culture:(選擇性)將值轉換成文字時要使用的文化特性(例如,“en-US”。

範例 1

根據數字 3 建立文字值。

使用方式

Text.From(3)

輸出

"3"

範例 2

取得與指定日期和時間相等的文字。

使用方式

Text.From(#datetime(2024, 6, 24, 14, 32, 22))

輸出

"6/24/2024 2:32:22 PM"

範例 3

取得相當於指定日期和時間的德文文字。

使用方式

Text.From(#datetime(2024, 6, 24, 14, 32, 22), "de-DE")

輸出

"24.06.2024 14:32:22"

範例 4

從編碼為十六進位的文字取得二進位值,並將值變更回文字。

使用方式

Text.From(Binary.FromText("10FF", BinaryEncoding.Hex))

輸出

"EP8="

範例 5

取得數據表中的數據列,其中包含法國的數據,並使用法文文化特性將日期轉換成文字。

使用方式

let
    Source = #table(type table [Company ID = text, Country = text, Date = date],
    {
        {"JS-464", "USA", #date(2024, 3, 24)},
        {"LT-331", "France", #date(2024, 10, 5)},
        {"XE-100", "USA", #date(2024, 5, 21)},
        {"RT-430", "Germany", #date(2024, 1,18)},
        {"LS-005", "France", #date(2023, 12, 31)},
        {"UW-220", "Germany", #date(2024, 2, 25)}
    }),
    #"Convert Dates" = Table.TransformColumns(
        Table.SelectRows(Source, each [Country] = "France"),
        {"Date", each Text.From(_, "fr-FR")}
    )
in
    #"Convert Dates"

輸出

#table(type table [Company ID = text, Country = text, Date = text],
{
    {"LT-331", "France", "05/10/2024"},
    {"LS-005", "France", "31/12/2023"}
})