数据类型Table.TransformColumnTypes(Power Query 之 M 语言)

数据源:

  任意数据源

目标:

  设置适合的数据类型

操作过程:

  选取指定列》【主页】》【数据类型】》选取

  选取指定列》【转换】》【数据类型】》选取

  选取指定列》【转换】》【检测数据类型】

  单击列标题左侧的【数据类型】按钮选取

M公式:

  = Table.TransformColumnTypes( 表,{{ "列名1", 指定类型1},...,{ "列名n", 指定类型n}}, "地区")

指定类型:

小数:type number / Number.Type

货币:Currency.Type

整数:Int64.Type

百分比:Percentage.Type

日期/时间:type datetime

日期:type date / Date.Type

时间:type time / Time.Type

日期/时间/时区:type datetimezone

持续时间:type duration / Duration.Type

文本:type text / Text.Type

逻辑值:type logical / Logical.Type

二进制:type binary / Binary.Type

其他数据类型:

  空值:null

  函数:function

  两种或两种以上的type:any

  不属于任何type:none

其他:

  日期表示法:=#date(年,月,日)

  时间表示法:=#time(时,分,秒)

  日期时间表示法:=#datetime(年,月,日,时,分,秒)

  日期时间时区表示法:=#datetimezone(年,月,日,时,分,秒,偏移小时,偏移分钟)

  持续时间表示法:=#duration(天,时,分,秒)

扩展:

  转二进制:

    = Text.ToBinary("文本型数字", encoding, 逻辑值)

    = Lines.ToBinary({"文本型数字"})

    = Binary.From(任意, encoding)

    = Binary.FromList({数值列表})

    = Binary.FromText("文本型数字", encoding)

posted @ 2021-05-29 21:35  熬肥妖  阅读(3230)  评论(0编辑  收藏  举报