简体   繁体   English

如何在 Google Data Studio 中用新行连接两个字段?

[英]How to concat two fields with a new line in the middle in Google Data Studio?

First, this is not the same as How to make a new line in Google Data Studio in the exception?首先,How to make a new line in Google Data Studio in the exception 不同? because that one is for writing a new connector and I am not trying to do that.因为那是为了编写一个新的连接器,而我并没有尝试这样做。

I want to concat two fields in a table column and put a new-line in the middle.我想在表列中连接两个字段并在中间换行。 Using \n does not seem to work.使用\n似乎不起作用。

I've built calculated fields like this:我已经构建了这样的计算字段:

concat([Field1],"\n","\n",[Field2])

that result in this within a table:结果在一个表中:

Field 1字段 1

Field 2领域 2

For some reason, when using a custom data source concatenating the new line character would not work under any tests I performed (I used every text manipulation function they have ).出于某种原因,当使用自定义数据源连接换行符时,在我执行的任何测试下都不起作用(我使用了他们拥有的每个文本操作 function )。 That approach, which matches Kellie's answer was:与 Kellie 的回答相符的方法是:

concat(field1, '\n\n', field2)

This only works with google analytics data sources where there isn't a date range dimension (I didn't test gsheets/others) and you must have "wrap text" on the table body enabled.这仅适用于没有日期范围维度(我没有测试 gsheets/其他)的谷歌分析数据源,并且您必须在表体上启用“换行文本”。 The work-around I found was to *NOT use data studio formatting in that you can put this in your data connector query/stored procedure.我发现的解决方法是*不使用数据工作室格式,因为您可以将其放入数据连接器查询/存储过程中。 A PostgreSQL example:一个 PostgreSQL 的例子:

select 
concat(field1, e'\n\n', field2) as newfield
from datatable;

Hopefully the datastudio team will fix this bug in the future (edit: the bug was with pivot tables, in that they do not recognize the new lines).希望 datastudio 团队将来会修复此错误(编辑:此错误与 pivot 表有关,因为它们无法识别新行)。

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

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