简体   繁体   English

PowerBi 如何将一列中的字符提取为 3 列

[英]PowerBi How to extract characters from a column into 3 columns

how are you all doing?你们都还好吗?

I need some help with the data im working on, I'm trying to breakdown a column into three new columns on PowerBI我需要一些关于正在处理的数据的帮助,我正在尝试在 PowerBI 上将一列分解为三个新列

在此处输入图像描述

Conditions条件

  1. if the characters starts with a Letter, it moves to the Left, else leave it blank如果字符以字母开头,则向左移动,否则留空
  2. If the character ends with a W, then move it to the Right如果字符以 W 结尾,则将其向右移动
  3. extract the numbers in between提取中间的数字
  4. get rid of the '%'摆脱'%'

实际数据集样本

The following changes this:以下内容对此进行了更改:

在此处输入图像描述

to this:对此:

在此处输入图像描述

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Score", type text}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type","%","",Replacer.ReplaceText,{"Score"}),
    #"Added Custom" = Table.AddColumn(#"Replaced Value", "Left", each if [Score] <> null then let check = try Number.From(Text.At([Score],0)) in if check[HasError] then Text.At([Score],0) else "" else ""),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Actual %", each if [Score] <> null then Text.Select([Score],{"0","1","2","3","4","5","6","7","8","9","."}) else ""),
    #"Added Custom2" = Table.AddColumn(#"Added Custom1", "Right", each if [Score] <> null then let check = try Number.From(Text.At([Score],Text.Length([Score])-1)) in if check[HasError] then Text.At([Score],Text.Length([Score])-1) else "" else "")
in
    #"Added Custom2"

How about怎么样

let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Left", each if Value.Is(Value.FromText(Text.Start([Column1],1)), type text) then Text.Start([Column1],1) else null),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Right", each if Value.Is(Value.FromText(Text.End([Column1],1)), type text) then Text.End([Column1],1) else null),
#"Added Custom2" = Table.AddColumn(#"Added Custom1", "Actual%", each Text.Select([Column1],{Character.FromNumber(48)..Character.FromNumber(57) } ))
in #"Added Custom2"
Column1第 1 列
D86W D86W
A45 A45
A88W A88W
88W 88W
88% 88%
A85W A85W
A66 A66
70W 70W
99% 99%
88 88
89W 89W
D86W D86W

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM