简体   繁体   English

如何清理 Power BI 中的乱码

[英]How to clean up gibberish text in Power BI

Is there a way to clean up text in Power BI?有没有办法清理 Power BI 中的文本? I have an Excel Spreadsheet with almost Five Hundred Thousand rows and I have imported into Power BI.我有一个几乎有 50 万行的 Excel 电子表格,并且我已导入 Power BI。 Is there a way in Power BI to cleanup a text like this in the screen shot below? Power BI 中有没有办法在下面的屏幕截图中清理这样的文本? I need to remove all those //, ***, ... and all other gibberish text etc. I did filter out those but there are almost five hundred thousand rows and Power Query doesn't load all and that option is not available.我需要删除所有这些 //、***、... 和所有其他乱码文本等。我确实过滤掉了这些,但有近 50 万行并且 Power Query 没有加载所有行,并且该选项不可用. Is there any other way than filtering in Power Query?除了在 Power Query 中过滤之外,还有其他方法吗?

在此处输入图像描述

There is no function for gibberish text.乱码文本没有 function。 The hardest part is to define what is gibberish.最难的部分是定义什么是乱码。 You can create a calculate column in M language with multiple OR statement like in this example and filter True/False;您可以使用 M 语言中的多个 OR 语句创建一个计算列,如本示例中并过滤 True/False;

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCkpNL81JLApOzStJzUtOVYrViVbS19cH08GJOanFYYk5pRBhPT09MO2SWJKIImBoZGxgYglm+qVWlKCYFZBYlJhelJhmAua55qTkFyWm5IM5iSk56ZlpKenFGWCuhhXMcgiAWYEAYBH3/PwUsMMUFUA6YgE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [gibberishOrNot = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"gibberishOrNot", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Text.Contains([gibberishOrNot],"//") or Text.Contains([gibberishOrNot], ".."))
in
    #"Added Custom"

Or you can add a Function to your model and try to run some Regex expresion:或者您可以将 Function 添加到您的 model 并尝试运行一些正则表达式:

Input Parameters: 
x : String to be searched
y:  search regex
z:  replacement regex
    = (x,y,z)=>
    let 
       Source = Web.Page(
                         "<script>var x="&"'"&x&"'"&";var z="&"'"&z&
                         "'"&";var y=new RegExp('"&y&"','g');
                         var b=x.replace(y,z);document.write(b);</script>")
                         [Data]{0}[Children]{0}[Children]{1}[Text]{0}
    in 
       Source

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

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