首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >连接字段的pbi m查询

连接字段的pbi m查询
EN

Stack Overflow用户
提问于 2022-05-10 19:02:02
回答 1查看 38关注 0票数 0

不熟悉PBI公式,但有点知道我在找什么。我有一个可能很长的注释字段,所以我想做的是

代码语言:javascript
运行
复制
if text.length([comment] > 45) then text.range(text.combine([comment],"..."),45) else [comment]

一些注释字段也将为null。我尝试过不同的变体,只是看不出它是正确的。感谢你的帮助。谢谢。

EN

回答 1

Stack Overflow用户

发布于 2022-05-10 19:10:07

注意,M是区分大小写的,所以text.length() Null和text.combine不能工作。您必须使用Text.Length()、Text.Combine()、null等。

试试这个:

代码语言:javascript
运行
复制
= try if Text.Length([comment])>45 then Text.Start([comment],45)&"..." else [comment] otherwise null

您可以使用add作为新的自定义列的一部分:

代码语言:javascript
运行
复制
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"

或转换现有列:

代码语言:javascript
运行
复制
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"
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72191767

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档