google data studio conditional statement on calculated field

丶灬走出姿态 提交于 2021-01-29 17:50:17

问题


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

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

Thanks in advance


回答1:


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

Calc Field 1: Summed Sales

SUM(sales)  

Calc Field 2: MyCaseField

CASE WHEN Summed Sales > 350000 THEN 1 ELSE 0 END  

From the Data Studio Docs:

...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.

Reference



来源:https://stackoverflow.com/questions/57824522/google-data-studio-conditional-statement-on-calculated-field

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!