Google Data Studio关于计算字段的条件语句 [英] google data studio conditional statement on calculated field

查看:51
本文介绍了Google Data Studio关于计算字段的条件语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Google Data Studio,并且正在尝试使用 case 语句创建一个计算字段,但是它不起作用.指标是销售.波纹管是示例行:

I am using google data studio and I am trying to create a calculated field using a case statement, but it is not working. The metric is sales. Bellow is the sample line:

CASE WHEN SUM(sales) > 350000 THEN 1 ELSE 0 END

上面的公式给了我一个错误.如果我按照下面的公式进行操作,它不会给出错误,但结果却不是我期望的:

The formula above gives me an error. If I do the formula bellow instead it doesn't give an error but the result is not what I expect:

CASE WHEN sales > 350000 THEN 1 ELSE 0 END

有什么主意吗?我也尝试使用 if 失败了.

Any idea what could be wrong ? I tried to use if as well without success.

预先感谢

推荐答案

我将创建两个计算字段.将下一个字段中的第一个计算字段与 CASE 语句一起使用:

I would create two calculated fields. Using the first calculated field in the next one with the CASE statement:

计算字段1:总销售额

SUM(sales)  

计算字段2:MyCaseField

CASE WHEN Summed Sales > 350000 THEN 1 ELSE 0 END  

从Data Studio文档中:

...无法在计算机中进行数学运算或使用计算出的字段函数当出现条件时... ...您可以先创建一个具有所需公式的计算字段.然后在CASE语句.

...It's not possible to do math or use calculated field functions in a WHEN condition... ...You can work around this by first creating a calculated field with the desired formula. Then use that field in the CASE statement.

参考

这篇关于Google Data Studio关于计算字段的条件语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆