简体   繁体   English

Data Studio - 计算字段 - 减去总事件

[英]Data Studio - Calculate Fields - Substraction of Total Events

I would like to create a calculated field, which would substract metrics total events from the event with more total events to event with less total events.我想创建一个计算字段,它将从总事件数较多的事件中减去指标总事件数到总事件数较少的事件。 Afterwards, I would like to create a line graph of this in DataStudio.之后,我想在 DataStudio 中创建一个折线图。

Basically, I would like to substract total events of the following events:基本上,我想减去以下事件的总事件:

Event Category: Game

Event Action: Game Session Started

minus

Event Category: Game

Event Action: Game Session Finished

I was trying in CASE with functions such as ABS, SUM etc.. however, I can't seem to find a solution.我在 CASE 中尝试使用 ABS、SUM 等函数。但是,我似乎找不到解决方案。 Thank you.谢谢你。

Here is an example: Example这是一个例子:例子

Try尝试

sum(case 
WHEN Event_Category = 'Game' and Event_Action='Game Session Started' THEN 'Total Events'
ELSE 0 END)
-
sum(case 
WHEN Event_Category = 'Game' and Event_Action='Game Session Finished' THEN 'Total Events'
ELSE 0 END)

You may need to split into 2 calculated metrics and then use a 3rd to minus the finished from the started.您可能需要拆分为 2 个计算指标,然后使用第 3 个从开始减去完成的指标。

I think this may not be feasible to do, however as you requested:我认为这可能不可行,但是按照您的要求:

Field 1 - SUM(CASE WHEN Event Category = 'Game' and Event Action ='Game Session Started' THEN 1 ELSE 0 END)字段 1 - SUM(CASE WHEN Event Category = 'Game' and Event Action ='Game Session Started' THEN 1 ELSE 0 END)

Field 2 - SUM(CASE WHEN Event Category = 'Game' and Event Action ='Game Session Finished' THEN 1 ELSE 0 END)字段 2 - SUM(CASE WHEN Event Category = 'Game' and Event Action ='Game Session Finished' THEN 1 ELSE 0 END)

Field 3 - (Field 1 - Field 2)字段 3 - (Field 1 - Field 2)

Field 4 - Count(Event Category)字段 4 - Count(Event Category)

Picture图片

in my case, recommendations with SUM(CASE WHEN Event Category = 'Game' and Event Action ='Game Session Started' THEN 1 ELSE 0 END) didn't work because basically, we need to mix dimensions with metrics...在我的例子中, SUM(CASE WHEN Event Category = 'Game' and Event Action ='Game Session Started' THEN 1 ELSE 0 END) 的建议不起作用,因为基本上,我们需要将维度与指标混合...

in the best case it has to be something like this: CASE WHEN Event Category = 'Game' and Event Action ='Game Session Started' THEN {{UNIQUE EVENTS}} ELSE 0 END but it does not work because we mix Event Category / Event Action (dimensions) with calculated result {{UNIQUE EVENTS}} (metric) - maybe in the future, it will work...在最好的情况下,它必须是这样的: CASE WHEN Event Category = 'Game' and Event Action ='Game Session Started' THEN {{UNIQUE EVENTS}} ELSE 0 END 但它不起作用,因为我们混合了 Event Category /具有计算结果的事件操作(维度){{UNIQUE EVENTS}}(指标)——也许在未来,它会起作用……

To fix this task, I did next: 1 created 2 independent tables, each of them filtering by a specific event 2 blend data adding 3rd table with a date for the shared timeline 3 in blended data source - calculated SUM(Total Events (game start))-SUM(Total Events (game finished))为了解决这个任务,我接下来做了: 1 创建了 2 个独立的表,每个表都按特定事件过滤 2 混合数据添加第 3 个表,其中包含共享时间轴的日期 3 在混合数据源中 - 计算 SUM(总事件(游戏开始))-SUM(总事件(游戏结束))

chart图表

data blending settings数据混合设置

filter for one table过滤一张表

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

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