不熟悉PBI公式,但有点知道我在找什么。我有一个可能很长的注释字段,所以我想做的是
if text.length([comment] > 45) then text.range(text.combine([comment],"..."),45) else [comment]
一些注释字段也将为null。我尝试过不同的变体,只是看不出它是正确的。感谢你的帮助。谢谢。
发布于 2022-05-10 19:10:07
注意,M是区分大小写的,所以text.length() Null和text.combine不能工作。您必须使用Text.Length()、Text.Combine()、null等。
试试这个:
= try if Text.Length([comment])>45 then Text.Start([comment],45)&"..." else [comment] otherwise null
您可以使用add作为新的自定义列的一部分:
let Source = #table({"comment"},{{"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"},{"Bus"},{null}, {"Car Log"}}),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"comment", type text}}),
#"Add Custom Column" = Table.AddColumn( #"Changed Type", "Custom", each try if Text.Length([comment])>45 then Text.Start([comment],45)&"..." else [comment] otherwise null)
in #"Add Custom Column"
或转换现有列:
let Source = #table({"comment"},{{"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"},{"Bus"},{null}, {"Car Log"}}),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"comment", type text}}),
#"Transform Column" = Table.TransformColumns(#"Changed Type",{{"comment", each try if Text.Length(_)>45 then Text.Start(_,45)&"..." else _ otherwise null, type text}})
in #"Transform Column"
https://stackoverflow.com/questions/72191767
复制相似问题