let
源 = Excel.Workbook(File.Contents("E:\數(shù)據(jù)分析CDA資料\A課件\Power BI數(shù)據(jù)加工及數(shù)據(jù)匯總分析\Power BI數(shù)據(jù)加工及數(shù)據(jù)匯總分析\Power Query數(shù)據(jù)處理\身份證號碼練習(xí)數(shù)據(jù).xlsx"), null, true),
身份證號碼_Sheet = 源{[Item="身份證號碼",Kind="Sheet"]}[Data],
提升的標(biāo)題 = Table.PromoteHeaders(身份證號碼_Sheet, [PromoteAllScalars=true]),
更改的類型 = Table.TransformColumnTypes(提升的標(biāo)題,{{"身份證號碼", type text}}),
已添加索引 = Table.AddIndexColumn(更改的類型, "序號", 1, 1),
重排序的列 = Table.ReorderColumns(已添加索引,{"序號","身份證號碼"}),
已插入文本范圍 = Table.AddColumn(重排序的列, "性別", each Text.Middle([身份證號碼], 16, 1), type text),
更改的類型1 = Table.TransformColumnTypes(已插入文本范圍,{{"性別", Int64.Type},{"序號",type text}}),
校驗(yàn)的為偶數(shù) = Table.TransformColumns(更改的類型1,{{"性別", Number.IsEven, type logical}}),
更改的類型2 = Table.TransformColumnTypes(校驗(yàn)的為偶數(shù),{{"性別", type text}}),
替換的值 = Table.ReplaceValue(更改的類型2,"true","女性",Replacer.ReplaceText,{"性別"}),
false替換為男性 = Table.ReplaceValue(替換的值,"false","男性",Replacer.ReplaceText,{"性別"}),
提取生日信息 = Table.AddColumn(false替換為男性, "生日信息", each Text.Middle([身份證號碼], 6, 8), type text),
更改的類型3 = Table.TransformColumnTypes(提取生日信息,{{"生日信息", type date}}),
提取地區(qū)信息 = Table.AddColumn(更改的類型3, "地區(qū)信息", each Text.Middle([身份證號碼], 0, 6), type text),
更改地區(qū)類型 = Table.TransformColumnTypes(提取地區(qū)信息,{{"地區(qū)信息", Int64.Type}}),
合并的查詢 = Table.NestedJoin(更改地區(qū)類型, {"地區(qū)信息"}, 對應(yīng)地名, {"ID"}, "對應(yīng)地名", JoinKind.LeftOuter),
#"展開的“對應(yīng)地名”" = Table.ExpandTableColumn(合并的查詢, "對應(yīng)地名", {"名稱"}, {"對應(yīng)地名.名稱"})
in
#"展開的“對應(yīng)地名”"









暫無數(shù)據(jù)