首页 > 解决方案 > 如何在powerbi中仅提取字母数字值

问题描述

数据 ABC123 JKL685 UJKLPN 655789

输出:ABC123 和 JKL685 显示为真,其余为假。如何实现这个场景。

标签: powerbi-desktop

解决方案


这是我使用 Power Query 的建议:

let
    numbers = List.Transform(List.Numbers(0,10), each Text.From(_) ),
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcnRyNjQyVorViVby8vYxszAFM0OB7AA/MNPM1NTcwlIpNhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Data = _t]),
    #"Filtered numerical" = Table.SelectRows(Source, each try if Value.Type(Number.From([Data])) = type number then false else true otherwise true),
    #"Filtered alphabetical" = Table.SelectRows(#"Filtered numerical" ,
        (FindStrings) => 

    List.AnyTrue(List.Transform(numbers, each Text.Contains((FindStrings[Data]),_ ))))
    
    
in
    #"Filtered alphabetical"

它首先通过尝试转换为数字并仅保留无法转换的行来过滤掉完整的数字条目。然后它过滤只包含字母的行。它可能不是非常有效,但适用于示例数据。


推荐阅读