Power Query 使用 <4 characters

问题描述 投票:0回答:2

使用Power Query 清理数据集。我正在尝试清除列中包含 4 个或更少字符的单元格,保留该列的剩余单元格(> 4 个字符)。

我用谷歌搜索了所有可能的方法来解释我的意图,但没有找到合适的解决方案。

excel powerbi powerquery powerbi-desktop m
2个回答
1
投票

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQyVorVAdMmcIYpgmWmFBsLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Replaced Value" = Table.ReplaceValue(Source,each [Column1],each if Text.Length([Column1]) > 4 then [Column1] else null,Replacer.ReplaceValue,{"Column1"})
in
    #"Replaced Value"

1
投票

使用变换而不是替换的替代方法。两者都不是更好

let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQyVorVAdMmcIYpgmWmFBsLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
Trim = Table.TransformColumns(Source,{{"Column1", each if Text.Length(Text.From(_)??"") <5 then null else _ }})
in  Trim
© www.soinside.com 2019 - 2024. All rights reserved.