Google Data Studio - 将数字范围乘以不同的百分比
Google Data Studio - Multiply Number Ranges by Varied Percentages
我确定我在这里做了一些愚蠢的事情,但我试图将某些数字范围乘以某些百分比并不断出现计算错误。 “THEN/ELSE 语句不能包含函数或数学运算。关闭”
有谁知道完成此任务的更好方法吗?
我的失败如下:
CASE
WHEN REGEXP_MATCH(Ad Budget,"200-9999") THEN SUM(Ad Budget*.30)
WHEN REGEXP_MATCH(Ad Budget,"10000-14999") THEN SUM(Ad Budget*.25)
ELSE "200"
END
下面的 SUM
section of the CASE
statement in the question, suggests that the Ad Budget
field is of the Number Semantic Type, thus, instead of using REGEXP_MATCH
, Comparison Operators (>=
<
) would do the trick; in addition, the 11 Mar 2021 Update included enhancements to Conditional Expressions in CASE
statements, thus the Calculated Field 应该可以解决问题:
SUM(CASE
WHEN Ad Budget >= 200 AND Ad Budget < 10000 THEN Ad Budget * 0.30
WHEN Ad Budget >= 10000 AND Ad Budget < 15000 THEN Ad Budget * 0.25
ELSE 200 END)
Editable Google Data Studio Report (Embedded Google Sheets 数据源)和一张 GIF 来详细说明:
我确定我在这里做了一些愚蠢的事情,但我试图将某些数字范围乘以某些百分比并不断出现计算错误。 “THEN/ELSE 语句不能包含函数或数学运算。关闭”
有谁知道完成此任务的更好方法吗?
我的失败如下:
CASE
WHEN REGEXP_MATCH(Ad Budget,"200-9999") THEN SUM(Ad Budget*.30)
WHEN REGEXP_MATCH(Ad Budget,"10000-14999") THEN SUM(Ad Budget*.25)
ELSE "200"
END
下面的 SUM
section of the CASE
statement in the question, suggests that the Ad Budget
field is of the Number Semantic Type, thus, instead of using REGEXP_MATCH
, Comparison Operators (>=
<
) would do the trick; in addition, the 11 Mar 2021 Update included enhancements to Conditional Expressions in CASE
statements, thus the Calculated Field 应该可以解决问题:
SUM(CASE
WHEN Ad Budget >= 200 AND Ad Budget < 10000 THEN Ad Budget * 0.30
WHEN Ad Budget >= 10000 AND Ad Budget < 15000 THEN Ad Budget * 0.25
ELSE 200 END)
Editable Google Data Studio Report (Embedded Google Sheets 数据源)和一张 GIF 来详细说明: